Username and Password not accepted when using nodemailer?

Viewed 74227

This is my settingController:

var sendSmtpMail = function (req,res) {
  var transport = nodemailer.createTransport({
  service:'gmail',
   auth: {
             user: "asdfqweerrccb@limitlesscircle.com",
             pass: "qwerr@wee"
        }
   });
   var mailOptions = {
        from: "transactions@limitlesscircle.com", 
        to:'umaraja1124@gmail.com', 
        subject: req.body.subject+"nodejs working ?", 
        text: "Hello world ?",  
    }
    transport.sendMail(mailOptions, function(error, response){
      if(error){
         res.send("Email could not sent due to error: "+error);
         console.log('Error');
       }else{
         res.send("Email has been sent successfully");
         console.log('mail sent');
      } 
  }); 

in postman I got the error like that:

Email could not sent due to error:

Error: Invalid login: 535-5.7.8 Username and Password not accepted. Learn more at 535 5.7.8  https://support.google.com/mail/?p=BadCredentials g7sm64435626pfj.29 - gsmtp
8 Answers

I encountered the same problem, i solved it as follows:

  1. GOTO https://admin.google.com and Login with the main account you used for setting up the business account and create users. Remember to use the main Email ID.

Main Screen after logging in

  1. Click on the Security Icon and you'll be taken to this page where you'll see Less secure apps section, click on it. enter image description here

  2. Now You'll see this, allow users or give permission here.enter image description here

  3. And you're not done yet, Not Go to the below link: https://myaccount.google.com/u/1/lesssecureapps

enter image description here

Now you'll see the switch. Enable it and try it'll definitely work.

Peace :)

You have to allow Less-Secure-Apps to access account settings in your google account - by default, this setting is off and you can simply turn it on. Image example

There are some account settings that are necessary for you to send through it using SMTP.

If you have two-step verification enabled on the account, you will need to use an application specific password (created in the Gmail account) in the device settings: Signing in using application-specific passwords

If not, please try this: sign into the Gmail account using a web browser at https://mail.google.com, then go to Settings > Accounts and Import > Other Google Account settings. Under Security, scroll down and enable access for less secure apps. This setting is required to enable SMTP, POP or IMAP access.

If there is still a problem, try clearing Captcha: visit https://accounts.google.com/DisplayUnlockCaptcha and sign in with the Gmail username and password. If necessary (it's usually not), enter the letters in the distorted picture then press Continue. This will allow ten minutes for the device to register as an approved connection. Note that you must use the account you are trying to add to the device - if the browser is already signed into another account, you must sign out first. Also, you must trigger the device to make a connection within ten minutes of pressing Continue.

Explanation from Google Support team

Related