我收到收件人错误:无法发送邮件 - 使用 npm 节点邮件程序发送电子邮件时没有收件人定义错误。我正在咨询文档中的示例。考虑使用我的真实电子邮件 abc@gmail.com。
var emailAddress = "abc@gmail.com";
mailOptions = {
from: "Admin <abc@gmail.com>", // sender address
to: emailAddress, // list of receivers
subject: "Hello", // Subject line
text: "hello", // plaintext body
html: "<b>Hello</b>" // html body
}
smtpTransport = nodeMailer.createTransport("SMTP",{
service: "Gmail",
auth: {
user: "abc@gmail.com",
pass: "123"
}
});
smtpTransport.sendMail(mailJson, function(error, response){
if(error){
console.log(error);
}else{
console.log("Message sent: " + response.message);
}
// if you don't want to use this transport object anymore, uncomment following line
smtpTransport.close(); // shut down the connection pool, no more messages
});