how to send multiple emails using sendgrid and and also edit header for website name

1.1k views Asked by At

I am trying to use send grid as an email platform for my php but the problem is I cannot send multiple emails as a CC header and also I cannot edit the FROM header to display a Name in front of the email address.

$from = "News Letter <[email protected]>" // cannot get the "News Letter" to Display
$cc = array("[email protected]","[email protected]");// doesnt send to arrays

$params = array(
    'api_user'  => $user,
    'api_key'   => $pass,
    'to'        => $to,
    'cc'        => $cc,
    'subject'   => $subject,
    'html'      => $body,
    'from'      => $headers
  );
1

There are 1 answers

0
Martyn Davies On BEST ANSWER

You need to use some additional fields in your $params array, like so:

$params = array(
  'api_user'  => $user,
  'api_key'   => $pass,
  'to'        => $to,
  'toname'    => 'Newsletter Person',
  'cc'        => $cc,
  'subject'   => $subject,
  'html'      => $body,
  'from'      => $headers,
  'fromname'  => 'Newsletter'
);

Sendind directly via the Mail.Send endpoint does not allow for an array in the CC field, however if you use the SendGrid PHP library then you can use and array for CC