PHP mailer multiple address [duplicate]

◇◆丶佛笑我妖孽 提交于 2019-11-27 06:13:37

You need to call the AddAddress method once for every recipient. Like so:

$mail->AddAddress('person1@domain.com', 'Person One');
$mail->AddAddress('person2@domain.com', 'Person Two');
// ..

Better yet, add them as Carbon Copy recipients.

$mail->AddCC('person1@domain.com', 'Person One');
$mail->AddCC('person2@domain.com', 'Person Two');
// ..

To make things easy, you should loop through an array to do this.

$recipients = array(
   'person1@domain.com' => 'Person One',
   'person2@domain.com' => 'Person Two',
   // ..
);
foreach($recipients as $email => $name)
{
   $mail->AddCC($email, $name);
}
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!