Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NodeMailer Invalid Login

Tags:

I am new to node.js programming .I am using nodemailer module for sending emails.

const nodemailer = require ('nodemailer'), credentials=require('./credentials.js'); var mailTransport=nodemailer.createTransport({     service:'Gmail',     auth: {         user : credentials.gmail.user,         pass : credentials.gmail.password,     } }); function sendMail(mail_id){     mailTransport.sendMail({         from: ' "my name" <[email protected]>',         to : mail_id,   //[email protected]         subject : 'Hello',         text: "Hello How do u do ?",     },function(err,info){         if(err){             console.log('Unable to send the mail :'+err.message);         }         else{             console.log('Message response : '+info.response);         }     }); } exports.sendMail=sendMail; 

This is my program for sending emails to different users. But I am getting Invalid Login . I don't have any idea why this is coming . I am new to node.js and server side scripting.
I am using my gmail username and password for credentials.
Please help me.

like image 266
Sri Harsha Avatar asked Nov 15 '14 17:11

Sri Harsha


1 Answers

One reason could be the 'modern security standard' protection from Gmail.

Check you gmail inbox for any new mail having subject "Google Account: sign-in attempt blocked"

If yes, open the mail and click on the link https://www.google.com/settings/security/lesssecureapps

set 'Access for less secure apps' to 'Turn on'. Try again, it should be working now.

like image 91
Sachin Avatar answered Oct 03 '22 04:10

Sachin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!