Avos Avos - 7 days ago 7
PHP Question

Sending multiple recipient using smtp mail php

I am using smtp mail, I would like to send mails to multiple receiver. This is the code that I found several days ago.

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;


How can I send mail to multiple recipient?
the second email wouldn't sent...

Answer

I've find my answer by my close friend,

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;
Comments