Nabs Nabs - 1 year ago 105
Node.js Question

NodeJS Sendrgrid Issue in sending email to multiple recepients

I am having issue in sending mails to multiple recipients.

My script is

var SendGrid = require('sendgrid').SendGrid;
var sendgrid = new SendGrid('<<username>>', '<<password>>');
to: '',
from: '',
bcc: ["",""],

I have two questions here

  1. Can I have array of recipients in to list?

  2. How to have an array of recipients in bcc list?

Solutions related to above two queries will be indeed helpful


Answer Source

You may use an array of recipients in both the to and bcc fields.

For example:

var SendGrid = require('sendgrid').SendGrid;
var sendgrid = new SendGrid('{{sendgrid username}}', '{{sendgrid password}}');      
    to: ['', ''],
    from: '',
    bcc: ['', ''],
    subject: 'This is a demonstration of SendGrid sending email to mulitple recipients.',
    html: '<img src="" style="width: 100%" />'

If this isn't working for you and Node isn't spitting out any errors, check to see if the emails are being sent, by logging into SendGrid's website and looking at the Email Activity Log.

One thing I came across while testing your code sample is if you're sending the to and bcc to the same gmail address, gmail will combine it all into one email (so it appears it didn't work). Make sure when testing you're sending email to entirely different accounts.

If you need some email accounts to test with Guerrilla Mail is an excellent option for creating temporary test accounts.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download