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
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.
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!