D
D
Denis11112018-09-23 13:07:44
Node.js
Denis1111, 2018-09-23 13:07:44

Missing credentials for "PLAIN"?

let nodemailer = require("nodemailer");

module.exports = function (code) {

  // Use Smtp Protocol to send Email
  let smtpTransport = nodemailer.createTransport({
    host: 'smtp.gmail.com',
    port: 587,
    secure: false,
    auth: {
      user: '[email protected]',
      password: '228password228'
    }
  });

  let mailOptions = {
    from: "MyAdmin Helper",
    to: "[email protected]",
    subject: "Send Email Using Node.js",
    text: `${code}`
  }

  smtpTransport.sendMail(mailOptions, function (error, response) {
    if (error) {
      console.log(error);
    } else {
      console.log("Message sent: " + response.message);
    }

    smtpTransport.close();
  });
}

I'm trying to send the code to the mail. I don't understand why you need auth?? I read nothing in the documentation. Why is it needed? What is the problem?
Gives an error:
{ Error: Missing credentials for "PLAIN"
at SMTPConnection._formatError (D:\Programmes\Projects\NodeJs\project\node_modules\nodemailer\lib\smtp-connection\index.js:606:19)
at SMTPConnection.login (D:\Programmes\Projects\NodeJs\project\node_modules\nodemailer\lib\smtp-connection\index.js:350:38)
at connection.connect (D:\Programmes\Projects\NodeJs\project\node_modules\nodemailer\ lib\smtp-transport\index.js:270:32)
at SMTPConnection.once (D:\Programmes\Projects\NodeJs\project\node_modules\nodemailer\lib\smtp-connection\index.js:188:17)
at Object.onceWrapper (events.js:273:13)
at SMTPConnection.emit (events.js:182:13)
at SMTPConnection._actionEHLO (D:\Programmes\Projects\NodeJs\project\node_modules\nodemailer\lib\smtp- connection\index.js:1128:14)
at SMTPConnection._processResponse (D:\Programmes\Projects\NodeJs\project\node_modules\nodemailer\lib\smtp-connection\index.js:762:20)
at SMTPConnection._onData (D :\Programmes\Projects\NodeJs\project\node_modules\nodemailer\lib\smtp-connection\index.js:558:14)
at TLSSocket._socket.on.chunk (D:\Programmes\Projects\NodeJs\project\node_modules\ nodemailer\lib\smtp-connection\index.js:709:51)
at TLSSocket.emit (events.js:182:13)
at addChunk (_stream_readable.js:283:12)
at readableAddChunk (_stream_readable.js:264:11)
at TLSSocket.Readable.push (_stream_readable.js:219:10)
at TLSWrap.onread (net.js:639:20) code: 'EAUTH', command: 'API' }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question