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。這是一個錯字嗎? –