I've been using SendGrid.com to handle password reset email requests for a few years without issue. I haven't changed anything and for the last two days all users have been getting an "Error: Invalid from email address" error on all email requests.
This is happening on all valid email addresses.
For the life of me I cannot figure out why this would randomly start happening. SendGrid seems to be running without issue on their end. I am waiting to get feedback from Sendgrid.
My set up:
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');
});
});