发送电子邮件到多个电子邮件地址
问题描述:
我想发送电子邮件给超过1人,我的代码是在node.js和我使用发送网格。当我用逗号分隔时,它不起作用。并且我还希望电子邮件的内容能够以HTML格式识别HTML标签。发送电子邮件到多个电子邮件地址
这些都是我的代码
let html = "<b>"+"Hi John and Dee! </br>Someone needs help from a
CultureMee Consultant!</br>" + "Name: " +name + "</br>"+ "Email: "
+email+ "</br>"+ "Phone: " +phone +"</br>"+"Organisation:
"+organisation+"</b>"+ "How can you help: " +howCanWeHelp +"</br>"
+"Good luck!</b>"
//let html ="hello"
var helper = require('sendgrid').mail;
var from_email = new helper.Email(email);
var to_email = new
helper.Email("[email protected],[email protected],[email protected]
apps.com");
var subject = "There is a new CultureMee Consultant Application";
var content = new helper.Content('text/plain', html);
var mail = new helper.Mail(from_email, subject, to_email, content);
var sg = require('sendgrid')(process.env.SENDGRID_API_KEY);
var request = sg.emptyRequest({
method: 'POST',
path: '/v3/mail/send',
body: mail.toJSON()
});
sg.API(request, function (error, response) {
if (error) {
console.log('Error response received');
}
console.log(response.statusCode);
console.log(response.body);
console.log(response.headers);
});
答
用于发送电子邮件到你需要发送电子邮件作为字符串数组多个用户。
to: [
{
email: '[email protected]',
},
{
email: '[email protected]',
},
],
你的意思是我应该这样写这部分? var to_email = new helper.Email([{email:[email protected]},{email:[email protected]},{email:mehrnoosh @ lizard- apps.com}]); – Mehr
是的,试试吧 –