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

使用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;
    
    点赞 打赏 评论

相关推荐 更多相似问题