使用smtp邮件发送多个收件人php

时间:2016-11-23 01:34:02

标签: php smtp

我正在使用smtp邮件,我想将邮件发送到多个接收器。这是我几天前发现的代码。

if($_SERVER["REQUEST_METHOD"] == "GET"):
$to = "ahmad@polymer.com, dwi.hyuga@gmail.com";
$cc = "";
$from = "prod@polymer.com";
$subject = "Daftar PR Karet";
$body = "
Berikut data PR karet pada tanggal $now :

$y

Note : pesan ini digenerate oleh computer.
Terima Kasih,
            ";
    $SMTPMail = new SMTPClient ($SmtpServer, $SmtpPort, $SmtpUser, `$SmtpPass, $from, $to, $cc, $subject, $body);`
    $SMTPChat = $SMTPMail->SendMail();
endif;

如何向多个收件人发送邮件? 第二封电子邮件不会发送......

1 个答案:

答案 0 :(得分:0)

我的好友,我找到了答案,

if($_SERVER["REQUEST_METHOD"] == "GET"):
data = (",", "ahmad@polymer.com,dwi.hyuga@gmail.com");
for($x=0;$x<count($data);$x++):
$to = $data[$x];
$cc = "";
$from = "prod@polymer.com";
$subject = "Daftar PR Karet";
$body = "
Berikut data PR karet pada tanggal $now :

$y

Note : pesan ini digenerate oleh computer.
Terima Kasih,
            ";
    $SMTPMail = new SMTPClient ($SmtpServer, $SmtpPort, $SmtpUser, `$SmtpPass, $from, $to, $cc, $subject, $body);`
    $SMTPChat = $SMTPMail->SendMail();
endfor;
endif;