我正在尝试第一次实现nodemailer并且收到以下终端错误:" TypeError:nodemailer.createTransport不是函数"
这是我的路线代码:
router.post('/reportHero', function(req, res){
var emailBody = req.body;
var transporter = nodemailer.createTransport({
service: 'Gmail',
auth: {
user: 'gmail email address',
pass: 'password'
}
});
var mailOptions = {
from: req.body.senderEmail,
to: req.body.recipientEmail,
subject: req.body.subject,
text: req.body.text
}
transporter.sendMail(mailOptions, function(error, info){
if(error){
console.log(error);
res.sendStatus(500);
}else{
console.log('Message sent: ' + info.response);
res.sendStatus(200);
};
});
});
有谁知道我为什么会收到这个错误?