Can someone help me send an email to multiple recipients in sendgrid v3 + node.js? I've noticed that when I enter several email addresses in the to
field, only the first email address receives the email. The email addresses after the first one do not receive the email:
send: function(email, callback) {
var from_email = new helper.Email(email.from);
var to_email = new helper.Email('emailUser1@gmail.com,emailUser2@gmail.com,emailUser3@gmail.com');
var subject = email.subject;
var content = email.content
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(err, res) {
console.log(res);
if(err) {
console.log('---error sending email:---');
console.log(err);
console.log(err.response.body);
callback(500);
} else {
callback(200);
}
});
}
In the example above, only emailUser1@gmail.com
receives the email; emailUser2@gmail.com
and emailUser3@gmail.com
do not receive the email.
Can someone help?
Thanks in advance!