以下代码将电子邮件发送给3个收件人,但是我想知道是否有一种方法(除了循环外),邮件的收件人只能在收到的邮件的“收件人”字段中看到其姓名,并且没有其他两个。
var nodemailer = require('nodemailer');
var smtpTransport = require('nodemailer-smtp-transport');
var mailAccountUser = '<YOUR_ACCOUNT_USER>'
var mailAccountPassword = '<YOUR_ACCOUNT_PASS>'
var fromEmailAddress = '<FROM_EMAIL>'
var transport = nodemailer.createTransport(smtpTransport({
service: 'gmail',
auth: {
user: mailAccountUser,
pass: mailAccountPassword
}
}))
var mail = {
from: fromEmailAddress,
to: [abc@gmail.com, def@gmail.com,ghi@gmail.com],
subject: "hello world!",
text: "Hello!",
html: "<b>Hello!</b><p><a href=\"http://www.yahoo.com\">Click Here</a></p>"
}
transport.sendMail(mail, function(error, response){
if(error){
console.log(error);
}else{
console.log("Message sent: " + response.message);
}
transport.close();
});