繁体   English   中英

向多个收件人发送电子邮件 - 抄送:和密送:在PHP中

[英]Sending an Email to Multiple Recipients - Cc: and Bcc: in php

该程序正在运行,但如何发送多个CC和BCC。

for($i = 0; $i < count($snteadd); $i++)
{
    $subjt    = $subject;
    $mess     = $message;
    $toinfo  .= $snteadd[$i];
    $headers  = "MIME-Version: 1.0 \r\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
    $headers .= "from: <$fromemailid>\r\n";
    $headers .= "Reply-To: <$fromemailid>\r\n";  
    $hedders .= "cc : <$sendCC>\r\n" ; 
    $headers .= "Bcc :  <$sendBCC>\r\n";
    $headers .= "X-Mailer: PHP 4.x";         
    $sendbcc = $snteadd[$i] .",";
    $sendbcc .= $sendCC . ",";
    $sendbcc .= $sendBCC;             

    if($jvl != $i) 
    {
        $toinfo .= ", ";
    }

    if($snteadd[$i] != "") 
    {
        $result = mail($sendbcc, $subjt, $mess, $headers);
        if(!$result)
        {     
            $subjdis     = "Auto Response for Message Sending Failed";
            $headersdis  = "MIME-Version: 1.0\r\n";
            $headersdis .= "Content-type: text/html; charset=iso-8859-1\r\n";
            $headersdis .="Message Sending Failed\r\n";
            $headersdis .= "From: <$fromemailid> \r\n";
            $msgdis = "Message Could not be Delivered to this Mail ID ".$snteadd[$i];
            mail($fromemailid, $subjdis, $msgdis, $headersdis);   
            print "We encountered an error sending your mail <br>";
            //echo $headersdis;
        }
    }
}

只需以逗号分隔的地址列表就可以为每个字段执行操作。 请注意,您的问题代码中有许多拼写错误。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM