1

I am getting this in postman -

{
     "code": "EAUTH",
     "response": "535-5.7.8 Username and Password not accepted. Learn more at\n535 5.7.8  
                  https://support.google.com/mail/?p=BadCredentials x7- 
                  20020aa784c7000000b005058d220b37sm21945855pfn.64 - gsmtp",
     "responseCode": 535,
     "command": "AUTH PLAIN"
}

 

Email And password not accepted , I have already gone through this question, and tried possible way to resolve this problem, but nothing worked out.

nodemailer code section -

let transporter = nodemailer.createTransport({
   host: 'smtp.gmail.com',
   port: 587,
   secure: false,
   auth: {
     user: 'mygmail@gmail.com',
     pass: 'mypassword'
   }
})

const info = await transporter.sendMail({
       from: 'mygmail@gmail.com',
       to: "person@gmail.com",
       subject: "subject",
       text: "text",
       html: `<h1> hello </h1>`
})

I have tried -

  • generate an app-specific password and use that in place of your actual password.

  • enabled the captcha (link)

  • enabled the IMAP setting in gmail->setting->Forwarding and POP/IMAP

I Read this - less secure app and google account

Any help would be appreciated.

Aman Ghanghoriya
  • 169
  • 3
  • 10

2 Answers2

1

const nodemailer = require('nodemailer');

const sendEmail = async () => {
const transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
  user: 'sender gmail',
  pass: 'sender password',
  },
});

const options = {
from: 'sender gmail',
to: 'receiver gmail',
subject: 'subject',
text: 'text',
};

await transporter.sendMail(options);
}; 

module.exports = sendEmail;
Onkar Kole
  • 1,197
  • 7
  • 13
1

You can not login to the smtp server using a login and password anymore. You could try using an apps password but as Less secure apps & your Google Account is being removed shortly this is probably not the best option.

enter image description here

I recommend looking into Xoauth2 this way you can authorize the user rather than relying upon their password. I would try adapting javascript-implicit-flow to see if this will work.

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449