我已经使用 SendGrid.com 处理密码重置电子邮件请求几年了,没有任何问题。我没有改变任何内容,但在过去的两天中,所有用户在所有电子邮件请求上都收到了一个 "错误:无效的发件人电子邮件地址" 的错误消息。
这种情况发生在所有有效的电子邮件地址上。
我简直想不出为什么会突然开始发生这种情况。 SendGrid 在他们的端上似乎没有问题。 我正在等待来自 Sendgrid 的反馈。
我的设置:
var nodemailer = require('nodemailer');
var sgTransport = require('nodemailer-sendgrid-transport');
app.post('/forgot', usernameToLowerCase, function(req, res, next) {
async.waterfall([
function(done) {
crypto.randomBytes(20, function(err, buf) {
var token = buf.toString('hex');
done(err, token);
});
},
function(token, done) {
User.findOne({ username: req.body.username }, function(err, user) {
if (!user) {
req.flash('error', 'No account with that email address exists.');
return res.redirect('/forgot');
}
user.resetPasswordToken = token;
user.resetPasswordExpires = Date.now() + 3600000; // 1 hour
user.save(function(err) {
done(err, token, user);
});
});
},
function(token, user, done) {
var options = {
auth: {
api_user: '=====',
api_key: '======'
}
}
var client = nodemailer.createTransport(sgTransport(options));
var email = {
from: 'BusinessName',
to: user.username,
subject: 'Reset Your Password',
text:'====='
};
client.sendMail(email, function(err) {
req.flash('success', 'An email was sent to ' + user.username + ' with further instructions.' );
done(err);
});
}
], function(err) {
if (err) return next(err);
res.redirect('/forgot');
});
});