NodemailerError - Invalid login: 535-5.7.8 Username and Password not accepted
I've been trying to setup a simple OTP verification system on my webpage using Nodemailer module, the whole code is a bit long, so here is a reproducible example, [server.js] ````````````````````````````````````````````````````````````````````` let nm = require('nodemailer'); let trans = nm.createTransport({ host: 'smtp.gmail.com', port: 465, secure: true, // use SSL auth: { user: '<myemailaddr@gmail.com>', pass: '<mypassword>' } }); let details = { from: '<myemailaddr@gmail.com>', to: '<somebodyemailaddr@domain.com>', subject: 'Heading', html: 'Some content' }; trans.sendMail(details, console.log); // one-liner handling ```````````````````````````````````````````````````````````````````` The above code outputs the following error: ----------------------------------------------------------------------------------- > Error: Invalid login: 535-5.7.8 Username and Password not accepted. ..... code: 'EAUTH', ..... command: 'AUTH PLAIN' ------------------------------------------------------------------------------------- I've tried changing my `transport` as per the article at https://www.w3schools.com/nodejs/nodejs_email.asp, `````````````````````````````````````````````````` let trans = nm.createTransport({ service: 'Gmail', // also tried 'gmail' auth: { user: '<myemailaddr@gmail.com>', pass: '<mypassword>' } }); `````````````````````````````````````````````````` But, it results in the same error. How to fix it? > Note: I've enabled "Access for less secure apps" in my gmail, and I don't have two-step verification turned on. Also, I'm using Windows 10, Node v10.x, Nodemailer v6.x. Please note that, I'm using www.sololearn.com :)