我正尝试在注册后向用户发送电子邮件。但是我对nodemailer模块的要求有问题。我收到以下错误:
-我的npm版本是:6.2.0
-我的节点的版本是:v8.11.1
-我的package.json看起来像这样:
-我发送电子邮件的功能如下:
sendEmail() {
var nodemailer = require("nodemailer");
nodemailer.createTestAccount((err, account) => {
let transporter = nodemailer.createTransport({
host: 'smtp.gmail.com',
port: 587,
secure: false,
auth: {
user: 'example@gmail.com',
pass: 'example'
}
});
let mailOptions = {
from: '"Example" <example@gmail.com>',
to: this.inputEmail.value,
subject: 'Successful registration!',
text: "Thank you registing with us!"
};
transporter.sendMail(mailOptions, (error, info) => {
if (error) {
return console.log(error);
}
console.log("Message sent: %s", info.messageId);
console.log("Preview URL: %s", nodemailer.getTestMessageUrl(info));
})
})
}