我们正在使用sendgrid发送电子邮件,
我们已经尝试过,
$email = new SendGrid\Email();
$emails = array("foo@bar.com", "another@another.com", "other@other.com");
$email->setTos($emails);
$email->setHtml(array($message1,$message1));
$sendgrid->send($email);
如何设置不同的 - 一次不同$email->setHtml(array($message1,$message1))
。
答案 0 :(得分:1)
根据我的理解,您希望向不同的电子邮件ID发送不同的邮件。
可以实现哪些目标$email = new SendGrid\Email();
$emails = array("foo@bar.com", "another@another.com", "other@other.com");
$message = array("message1","message2","message3"); //create a array of messages according to email ids
$i =0 ;
foreach ($emails as $value) {
$email->setTos($value);
$email->setHtml($message[$i]);
$sendgrid->send($email);
$i++;
}
答案 1 :(得分:1)
由于您的问题令人困惑,我将假设您要向列表中的所有用户发送不同的电子邮件。所以:
$email = new SendGrid\Email();
$emails = array("foo@bar.com", "another@another.com", "other@other.com");
$messages = array("message1", "message2");
foreach ($messages as $msg) { // Grab every message...
$email->setTos($emails); // for everyone...
$email->setHtml($msg); // set it as the body...
$sendgrid->send($email); // and send it.
}