At the time of writing, Less Secure Apps is no longer supported by google. And you can’t use your google account password.
You’re gonna have to generate a new app password.
App passwords only work if 2-step verification is turned on.
Follow this steps to get the app password
- Go to https://myaccount.google.com/security
- Enable 2FA
- Create App Password for Email
- Copy that password (16 characters) into the pass parameter in Nodemailer auth.
const client = nodemailer.createTransport({
service: "Gmail",
auth: {
user: "[email protected]",
pass: "Google-App-Password-Without-Spaces"
}
});
client.sendMail(
{
from: "sender",
to: "recipient",
subject: "Sending it from Heroku",
text: "Hey, I'm being sent from the cloud"
}
)