Nodemailer: Error: Missing credentials for "PLAIN" at SMTPConnection._formatError

Created on 17 Jul 2019  Â·  3Comments  Â·  Source: nodemailer/nodemailer

Hi I am trying to setup nodemailer with gmail and so far I have been following this video:

Here is my code:
`
const nodemailer = require("nodemailer");
const xoauth2 = require('xoauth2');

// create reusable transporter object using the default SMTP transport
let transporter = nodemailer.createTransport({
  service: "gmail",
  auth: {
    xoauth2:  xoauth2.createXOAuth2Generator({
      user: "[email protected]",
      clientId: 'xxxxxxxxxxxxxxxxx',
      clientSecret: 'xxxxxxxxxxxxxxxxx',
      refreshToken: 'xxxxxxxxxxxxxxxxx'
    })
  }
});

// send mail with defined transport object
let mailOptions = {
  from: '"Fred Foo 👻" <[email protected]>', // sender address
  to: "[email protected]", // receiver address
  subject: "Hello ✔", // Subject line
  text: "Hello world?", // plain text body
  html: "<b>Hello world?</b>" // html body
};

transporter.sendMail(mailOptions, (error, res) => {
  if (error) {
    console.log(error);
  }else {
    console.log("email is sent");
  }
})

`

I am getting this error:
{ Error: Missing credentials for "PLAIN" at SMTPConnection._formatError (/home/xxxxxx/projects/my-projects/test/node_modules/nodemailer/lib/smtp-connection/index.js:781:19) at SMTPConnection.login (/home/xxxxxx/projects/my-projects/test/node_modules/nodemailer/lib/smtp-connection/index.js:452:38) at connection.connect (/home/xxxxx/projects/my-projects/test/node_modules/nodemailer/lib/smtp-transport/index.js:271:32) at SMTPConnection.once (/home/xxxxx/projects/my-projects/test/node_modules/nodemailer/lib/smtp-connection/index.js:209:17) at Object.onceWrapper (events.js:286:20) at SMTPConnection.emit (events.js:198:13) at SMTPConnection._actionEHLO (/home/xxxxxxx/projects/my-projects/test/node_modules/nodemailer/lib/smtp-connection/index.js:1309:14) at SMTPConnection._processResponse (/home/xxxxxxxx/projects/my-projects/test/node_modules/nodemailer/lib/smtp-connection/index.js:940:20 ) at SMTPConnection._onData (/home/xxxxxxxxx/projects/my-projects/test/node_modules/nodemailer/lib/smtp-connection/index.js:746:14) at TLSSocket.SMTPConnection._onSocketData (/home/xxxxxxxxx/projects/my-projects/test/node_modules/nodemailer/lib/smtp-connection/index.js :189:46) code: 'EAUTH', command: 'API' }

Version Numbers

os: ubuntu 19.04
node 10.16.0
nodemailer 6.3.0

I do not understand which credentials are missing as I have provided them. I have looked on almost all the articles on this issue and none have helped.

Also a quick question: Is it possible to use nodemailer on just a create-react-app without having to setup a backend for it?

Thanks in advance

wontfix

Most helpful comment

Did you ever figure this out? I'm on a deadline and this error has all of a sudden crept into my project. It was running fine and I think the only thing I may have changed between when it was running and now is my google account authentication. Any ideas would be very welcomed!

All 3 comments

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Did you ever figure this out? I'm on a deadline and this error has all of a sudden crept into my project. It was running fine and I think the only thing I may have changed between when it was running and now is my google account authentication. Any ideas would be very welcomed!

For me, it was due to not adding my Gmail password to the .env file.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tegarkurniawan picture tegarkurniawan  Â·  3Comments

connor11528 picture connor11528  Â·  6Comments

pkaminski picture pkaminski  Â·  5Comments

JYC-99 picture JYC-99  Â·  6Comments

molerat619 picture molerat619  Â·  3Comments