I've got a basic email setup done for sending email using Nodemailer with AngularJS and NodeJS and I've got the project deployed on heroku.
The emailing seems to be working just fine when I am running the app on heroku, but when I get it deployed to Heroku no emails are sent.
For authenticaion I am using a gmail address and I also have a bcc
to another gmail address. So from
and bcc
addresses are two different gmail addresses. The from
address is same as the address used for authentication.
Could somebody help me with resolving this issue?
Edit: Adding code
var nodemailer = require('nodemailer');
var transporter = nodemailer.createTransport({
service: 'Gmail',
auth: {
user: '[email protected]',
pass: 'foobar'
}
});
router.post('/send',function(req,res){
var mailOptions = {
from: 'Foo Bar ✔ <[email protected]>',
to: req.body.email,
subject: "Hello " + req.body.email,
text: 'Hello ' + req.body.email + '✔',
html: "<p>Hello " + req.body.email + " </p>",
bcc: "[email protected]"
};
transporter.sendMail(mailOptions, function(error, info){
if(error){
console.log(error);
}else{
console.log('Message sent: ' + info.response);
res.send(200);
}
});
});
I believe this is issue with google account security. - Google blocked your sign in to use the mailing features due to unknown device (location).
A few step to verify this:
Start your server locally and sends the email.
Check your account alerts for unknown sign in.
This can be temporally resolved by: https://accounts.google.com/DisplayUnlockCaptcha
More permanent resolution would be to change your password to a stronger level:
upper case letter + lower case letter + special symbols + numbers