Gmail has some security rules that needs to be taken care before able to send mail using NodeMailer.
Below is how the configurations to be done.
1. Login gmail account.
2. Enable pop3 in settings tabs
3. Enable less secure apps at: https://myaccount.google.com/lesssecureapps
4. Display Unlock Captcha at: https://accounts.google.com/b/0/DisplayUnlockCaptcha
5. Defined email option and sending
var mailOptions = {
host: 'smtp.gmail.com',
port: 465,
secure: true, // use SSL
auth: {
user: 'gmail_account@gmail.com',
pass: 'password'
}
}
mailer = nodemailer.createTransport(mailOptions);
mailer.sendMail({
....
}, function(err, response) {
if (err) {
console.log(err);
}
console.log(response);
});
Below is how the configurations to be done.
1. Login gmail account.
2. Enable pop3 in settings tabs
3. Enable less secure apps at: https://myaccount.google.com/lesssecureapps
4. Display Unlock Captcha at: https://accounts.google.com/b/0/DisplayUnlockCaptcha
5. Defined email option and sending
var mailOptions = {
host: 'smtp.gmail.com',
port: 465,
secure: true, // use SSL
auth: {
user: 'gmail_account@gmail.com',
pass: 'password'
}
}
mailer = nodemailer.createTransport(mailOptions);
mailer.sendMail({
....
}, function(err, response) {
if (err) {
console.log(err);
}
console.log(response);
});
references:
https://stackoverflow.com/questions/14654736/nodemailer-econnrefused
No comments:
Post a Comment