向多个收件人发送电子邮件 – 抄送:和密送:在PHP中
发布时间:2020-12-13 22:13:03 所属栏目:PHP教程 来源:网络整理
导读:该程序正在运行,但如何发送多个CC和BCC. for($i = 0; $i count($snteadd); $i++){ $subjt = $subject; $mess = $message; $toinfo .= $snteadd[$i]; $headers = "MIME-Version: 1.0 rn"; $headers .= "Content-type: text/html; charset=iso-8859-1rn";
|
该程序正在运行,但如何发送多个CC和BCC.
for($i = 0; $i < count($snteadd); $i++)
{
$subjt = $subject;
$mess = $message;
$toinfo .= $snteadd[$i];
$headers = "MIME-Version: 1.0 rn";
$headers .= "Content-type: text/html; charset=iso-8859-1rn";
$headers .= "from: <$fromemailid>rn";
$headers .= "Reply-To: <$fromemailid>rn";
$hedders .= "cc : <$sendCC>rn" ;
$headers .= "Bcc : <$sendBCC>rn";
$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.0rn";
$headersdis .= "Content-type: text/html; charset=iso-8859-1rn";
$headersdis .="Message Sending Failedrn";
$headersdis .= "From: <$fromemailid> rn";
$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;
}
}
}
解决方法
只需以逗号分隔的地址列表就可以为每个字段执行操作.请注意,您的问题代码中有许多拼写错误.
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
