The code below is perfect to send emails using node.js code/program. However, still getting error mentioned in the title.
var nodemailer = require('nodemailer'); var transporter = nodemailer.createTransport({ service: 'gmail', auth: { user: '[email protected]', pass: '**********' } }); var mailOptions = { from: '[email protected]', to: '[email protected]', subject: 'Sending Email using Node.js', text: 'That was easy!' }; transporter.sendMail(mailOptions, function(error, info){ if (error) { console.log(error); } else { console.log('Email sent: ' + info.response); } });
If getting "Username and Password not accepted" 535 5.7. 8 error, but user name and password work logging onto email via web (with 2-factor authentication), you may need to enable "Access for less secure apps" (allow exceptions to 2-factor authentication) in your email settings.
Back to Security in "Signing in to Google" section choose App passwords. From the Select app drop down choose Other (Custom name) and put a name e.g. nodemailer. A modal dialog will appear with the password. Get that password and use it in your code.
Incorrect Username and Password When the username and password entered in the Email client are incorrect, it ends up in Error 535. Again, using the wrong the mail server can also cause authentication failures. Usually, such mismatch in email login and password will be recorded in the mail server logs.
Error: Invalid login: 535-5.7.8 Username and Password not accepted. Learn mor... - DEV Community Error: Invalid login: 535-5.7.8 Username and Password not accepted. Learn more at
In short,“ SMTP Error (535): Authentication failed” error happens when there is a problem with SMTP configuration of email clients. Today, we saw how Bobcares solved “SMTP Error 535 Authentication failed”.
Google disabled less secure apps, to resolve the issue one need to setup "Login with app password" and to allow the app password "setup two factor authentication" when 2-Step-Verification is on and one get a "password incorrect" error, sign in to your account and go to security, try to use an App Password.
Yes, code is perfect. However, you need to allow less secure apps from your google account to send emails. Through this link. Allow less secure apps From your Google Account
Go to Less secure app access . convert icon Allow less secure apps to ON.
Link : https://myaccount.google.com/lesssecureapps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With