Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
向多个收件人发送电子邮件-php中的Cc:和Bcc:_Php_Email - Fatal编程技术网

向多个收件人发送电子邮件-php中的Cc:和Bcc:

向多个收件人发送电子邮件-php中的Cc:和Bcc:,php,email,Php,Email,此程序正在运行,但如何发送多个抄送和密件抄送 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

此程序正在运行,但如何发送多个抄送和密件抄送

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;
        }
    }
}
for($i=0;$i”;
//echo$headersdis;
}
}
}

每个字段只需一个逗号分隔的地址列表即可。请注意,您的问题中的代码中有许多拼写错误。

@Rajesh-如果答案对您有效,请接受它。您知道协议是否允许逗号后有空格,并且普遍接受吗?我不知道,但很容易测试。您也可以查看相关的RFC。