3
我收到收件人错误:无法发送邮件 - 使用npm节点邮件发送电子邮件时没有收件人定义的错误。我正在参考文档中的示例。考虑[email protected]与我真正的电子邮件。无法发送邮件节点邮件
var emailAddress = "[email protected]";
mailOptions = {
from: "Admin <[email protected]>", // 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: "[email protected]",
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
});
的电子邮件地址是一个字符串?现在[email protected]缺少引号 –
是的,它是一个字符串 –
此外,您传递给sendMail的选项不是mailOptions。这是一个错字吗? –