使用amazon-ses-php SDK发送多封电子邮件



根据亚马逊的文档,如果我想在一次通话中发送多封电子邮件,我可以像这个一样添加它

$recipient_emails = ['recipient1@example.com','recipient2@example.com'];

但是我希望能够发送用户的名字,这样我就知道正确的格式是

$recipient_emails = ["recipient1@example.com <recipient2@example.com>"];

我很难找到任何文件,但我想我可以用多封电子邮件发送这个名字

$recipient_emails = ["recipient1 <recipient2@example.com>", "recipient2 <recipient2@example.com>"];

在我的代码中,我试图正确地构建电子邮件,但我不确定我的代码是否错误,或者我不能用上面的例子发送电子邮件的名称。

if ($thisisanarray == 1) {
foreach ($to_email as $to_emails) {
$name = $to_emails['name'];
$username = $to_emails['username'];
$recipient_emails_arr[] = "$name <$username>";
}
$recipient_emails = implode(",",$recipient_emails_arr);
$recipient_emails = [$recipient_emails];
}

有人能帮忙吗?

如果AWS API接受接收者数组,则不需要代码中的最后两行。试着直接通过$recipient_emails_arr。否则,您将创建单个字符串,而不是收件人数组。

最新更新