在发送网格中保留收件人 API

preserve recipients in the sendgrid API

我正在使用 sendgrid API !

向多个收件人发送电子邮件
<?php


$email = new SendGrid\Email();
$sendgrid = new SendGrid('API_KEY');

$email
    ->addTo(array('first@mail.com','second@mail.com'..))
    ->setFrom('my@mail.com')
    ->setSubject('Subject goes here')
    ->setText('Hello World!')
    ->setHtml('<strong>Hello World!</strong>')
;

$sendgrid->send($email);

现在,我想知道是否有任何方法可以在第一封邮件的"To" header 中隐藏第二封邮件?

使用 SMTP API 进行邮件合并类型的功能。

使用 sendgrid-php,看起来像:

$email = new SendGrid\Email();
$email
    ->addSmtpapiTo('foo@bar.com')
    ->addSmtpapiTo('another@another.com', 'Mike Bar')
;
$sendgrid->send($email);

或者对于数组:

$email = new SendGrid\Email();
$emails = array("foo@bar.com", "Brian Bar <bar@example.com>", "other@example.com");
$email->setSmtpapiTos($emails);
$sendgrid->send($email);