I\'m trying to send the email gmail smtp but I\'m getting the error:
My email and password is correct I\'m using the nodemailer for sending the mail;
In case you're using OAuth2 and you're facing the issue above, configuring my transporter as shown below resolved my issue.
const transporter = nodemailer.createTransport({
host: 'smtp.gmail.com',
port: 465,
secure: true,
auth: {
type: 'OAuth2',
user: process.env.MAIL_USER,
clientId: process.env.GOOGLE_CLIENT_ID,
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
refreshToken: process.env.GOOGLE_CLIENT_REFRESH_TOKEN
}
});
If you're unsure how to generate the id, secret and token, follow the steps here https://medium.com/@pandeysoni/nodemailer-service-in-node-js-using-smtp-and-xoauth2-7c638a39a37e