我正在使用nodemailer向我发送电子邮件。我已经安装了软件包但是我在运行它时似乎收到了一条错误消息"错误未定义"
/* Render home page. */
router.get('/reset', function (req, res, next) {
if (!req.user) {
res.render('reset', {
title: 'Password Reset',
displayName: req.user ? req.user.displayName : ''
});
}
});
/* Render home page. */
router.post('/reset', function (req, res, next) {
var transporter = nodemailer.createTransport({
service: 'Gmail',
auth: {
user: 'myemail',
pass: 'email'
}
});
var mailOption = {
to: 'myemail.com',
subject: 'Test',
text: 'Try email' + req.body.name + 'Email' + req.body.email
}
transporter.sendMail(mailOption, function (err, info) {
if (error) {
console.log(err);
res.redirect('/');
}
else {
console.log('Send Message: ' + info.response);
res.redirect('/');
}
});
});
答案 0 :(得分:0)
当您致电transporter.sendMail
时,您会在回调函数中使用err
作为参数,但请尝试检查error
。