【发布时间】:2018-05-21 15:33:28
【问题描述】:
我尝试在 nodejs 中使用 nodemailer-smtp-transport 发送多封电子邮件,但如果多个收件人列表包含有效和无效的电子邮件 ID,则邮件不会发送到有效的电子邮件,总是会出错回调。
我的示例代码:-
var testemails=["name.@gmail.com,santosh@gmail.com"];
var mailOptions = {
from:config.email_from_addr,
//bcc :receiver_email,
bcc:testemails,
subject :subject,
html:html
};
var transporter = nodemailer.createTransport(smtpTransport({
host:config.email_host_name,
port: 25
}));
transporter.sendMail(mailOptions, function(error, info){
console.log("error: "+error);
console.log("info: "+info);
if(error){
//console.log("Rejected: "+info.rejected);
console.log("error",'Failed to send: '+subject+' ; Error: '+error);
return callback(null);
}else{
console.log("info","Promotion_EmailFurnished: "+subject+" : "+receiver_email);
return callback(null);
}
});
//此处无效电子邮件:name.@gmail.com 和 有效的 emailId:santosh@gmail.com 以及因无效邮件导致邮件发送失败如何收款?
有什么帮助吗?
谢谢提前。
【问题讨论】:
-
您是否尝试过逐个发送,例如使用
testemails.forEach(addr => {...})? -
你好 ionizer,是的,我试过了,它无法发送无效的电子邮件并发送到有效的 id,但我不想再次迭代到数组所以
标签: node.js nodemailer