我认为这工作正常,直到我意识到当我在gmail中收到邮件时,发件人(来自)是myemail@gmail.com
?它应该来自req.body.email
对吗?
router.post('/send_message', function(req,res) {
// create reusable transporter object using SMTP transport
var transporter = nodemailer.createTransport({
service: 'Gmail',
auth: {
user: 'myemail@gmail.com',
pass: 'pass'
}
});
transporter.sendMail({
from: req.body.email,
to: 'myemail@gmail.com',
subject: req.body.subject,
text: req.body.message
}, function(err, info) {
res.send('Emailed successfully');
});
});