向多个收件人发送电子邮件 - 抄送:和密送:在php
问题描述:
该程序正在运行,但如何发送多个抄送和密件抄送。向多个收件人发送电子邮件 - 抄送:和密送:在php
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;
}
}
}
答
只是一个逗号分隔的地址列表应该为每个字段做。请注意,您的问题中的代码中存在大量错字。
@Rajesh - 如果答案适合您,请接受它。 – 2010-11-16 00:25:23
你知道协议允许逗号后的空格,并且通常被接受吗? – 2017-11-28 21:25:34
我不知道副手,但它很容易测试。你也可以检查相关的RFC(s)。 – 2018-01-30 23:04:27