dongleibeng5602 2016-11-23 01:34
浏览 146
已采纳

使用smtp邮件发送多个收件人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...

  • 写回答

1条回答 默认 最新

  • doushifen4060 2016-11-25 00:42
    关注

    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;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?