Node.js 向多个电子邮件地址发送电子邮件

Node.js 向多个电子邮件地址发送电子邮件,node.js,sendgrid,Node.js,Sendgrid,我想向不止一个人发送电子邮件,我的代码在node.js中,我正在使用send grid。当我用逗号分隔时,它不起作用。而且我还希望电子邮件的内容是html格式,知道html标记 这是我的密码 let html = "<b>"+"Hi! </br>Someone needs help from a Consultant!</br>" + "Name: " +name + "</br>"+ "Email: " +email+ "</b

我想向不止一个人发送电子邮件,我的代码在node.js中,我正在使用send grid。当我用逗号分隔时,它不起作用。而且我还希望电子邮件的内容是html格式,知道html标记

这是我的密码

 let html = "<b>"+"Hi! </br>Someone needs help from a 
 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("x@emain.com,h@email.com,me@email.com");
var subject = "There is a new 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: 'email1@email.com', 
  },
  {
    email: 'email2@email.com', 
  },
],

另外,请检查并获取详细示例。

是,尝试这样做是否回答了您的问题?