How to send mails with Gmail using nodemailer after less secure app is disabled by Google?

Lizen Shakya
2 min readDec 27, 2022

The application that I have been working on fine, it send email using nodemailer with gmail. But a while back some modules start to crash and I had no idea what was going on. Everything seems to be working fine, the code was fine but still some modules which was working perfectly before started to crash.

So, after debugging for quite a bit finally I seem to notice that the modules which were suppose to send the mails had some problems. I searched online for help, the only solution I found was to disable less secure app in google.

But the problem was the message google disabled less secure app

So how can we send emails using gmail with nodemailer now. Lets check below.

You’re gonna have to generate a new app password.

App passwords only work if 2-step verification is turned on.

Below are the steps to generate app password.

  • Go to
  • Enable 2FA (Two factor authentication).
  • After enabling the two factor authentication, click on app password.
  • Create App Password for Email, select mail for app and you can give custom name for device.
  • Copy that password (16 characters) into the pass parameter in nodemailer authentication(auth).
const nodemailer = require("nodemailer");

const client = nodemailer.createTransport({
service: "Gmail",
auth: {
user: "Your email",
pass: "Google App Password Without Spaces"

from: "sender",
to: "recipient",
subject: "Sending",
text: "Hello"

Now this should work.
For more details please do check