Nodemailer,Heroku,Gmail,无效登录
我在过去几周一直遇到这个问题,它每次都在本地工作,但是一旦我将它部署到我的heroku服务器,它会给我一个invalid login
错误。我已经进入帐户并且可以访问不太安全的应用程序。并且凭据是正确的,并且它每次都在localhost上工作。有什么我想念的吗?
quickSendMail: function(routeBody, callback) {
//configuring the nodemailer for email notifications
var smtpConfig = {
host: 'smtp.gmail',
port: 465,
secure: true, // use SSL
auth: {
user: 'mysmtpemail123',
pass: '******'
}
};
var mailOptions = {
from: 'SageStorm Site <[email protected]>',
to: ['my email'],
subject: routeBody.subject,
html: 'my message'
};
var transporter = nodemailer.createTransport(smtpConfig);
transporter.verify(function(error, success) {
if (error) {
console.log(error);
} else {
console.log('server is ready to send emails');
}
})
transporter.sendMail(mailOptions, function(error, info) {
if (error) {
console.log(error);
return callback(err, null);
} else {
console.log('Message sent: ' + info.response);
return callback(null, info);
}
})
}
回答如下:
试试this,它将允许机器远程访问你的Gmail。
如果这不起作用,请尝试将您的nodemailer更新到最新版本。