NodeJS Sendgrid Issue in sending email to multiple recipients

前端 未结 5 1106
清酒与你
清酒与你 2020-12-21 03:31

I am having issue in sending mails to multiple recipients.

My script is

var SendGrid = require(\'sendgrid\').SendGrid;
var sendgrid = new SendGrid(\         


        
5条回答
  •  旧时难觅i
    2020-12-21 04:07

    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}}');      
    sendgrid.send({
        to: ['one@example.com', 'two@example.com'],
        from: 'nick@sendgrid.com',
        bcc: ['three@example.com', 'four@example.com'],
        subject: 'This is a demonstration of SendGrid sending email to mulitple recipients.',
        html: ''
    });
    

    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.

提交回复
热议问题