How to send emails with google using nodemailer after Google disabled less sure app option?

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

  1. Go to https://myaccount.google.com/security
  2. Enable 2FA
  3. Create App Password for Email
  4. 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"
    }
)

Leave a Comment