sendgrid / sendgrid-nodejs

The Official Twilio SendGrid Led, Community Driven Node.js API Library
https://sendgrid.com
MIT License
3k stars 782 forks source link

sendMultiple (only in production mod ) doesn't send email to recipients array #1349

Closed StudioOrientExpress closed 2 years ago

StudioOrientExpress commented 2 years ago

Issue Summary

Hello, I use the sendMultiple method to send an email to multiple recipients. When I'm in my development environment, everything works fine. All recipients receive the email. But in production, only one recipient receives the email. My environment variables are well informed at my provider. Thanks for your help.

Code Snippet

import sendgrid from '@sendgrid/mail';

sendgrid.setApiKey(process.env.SENDGRID_API_KEY);

export default async function sendEmailDestinataire(req, res) {
  const msg = {
    to: req.body.email, // is ['user@domaine1.fr', 'user@domaine2.com']
    from: {
      email: 'my@email.fr',
      name: 'My Name',
    },
    templateId: 'd-xxxx',
    dynamic_template_data: {
      name: req.body.name,
      email: req.body.email,
      message: req.body.message,
      file: req.body.file,
    },
  };
  try {
    await sendgrid.sendMultiple(msg);
    res.json({ message: `Email has been sent` });
  } catch (error) {
    res.status(500).json({ error: 'Error sending email' });
  }
}

Technical details:

JenniferMah commented 2 years ago

Hi @StudioOrientExpress! Are there any errors that occur when trying to send to multiple recipients?

StudioOrientExpress commented 2 years ago

Hi @JenniferMah, Send is success without errors. But only one recipient receive email

JenniferMah commented 2 years ago

In order to better serve you, as this does not present itself as a library specific issue, we would like to ask that you reach out to our support team at support.sendgrid.com.

StudioOrientExpress commented 2 years ago

Thanks, Hi send message to support sendgrid.