使用Amazon ses php PHP发送多封电子邮件

问题描述 投票:0回答:1

根据Amazon's Doc's,如果我想在一个呼叫中发送多封电子邮件,可以像这样简单地添加它

$recipient_emails = ['[email protected]','[email protected]'];

但是我也希望能够发送用户名,所以我知道正确的格式是

$recipient_emails = ["[email protected] <[email protected]>"];

我很难找到任何文档,但我想我可以通过多封电子邮件发送名称

$recipient_emails = ["recipient1 <[email protected]>", "recipient2 <[email protected]>"];

在我的代码中,我试图正确构造电子邮件,但是不确定我的代码是否错误,或者无法使用上面的示例通过电子邮件发送名称。

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];
}

任何人都可以帮忙吗?

php arrays amazon-web-services amazon-ses
1个回答
0
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.