【发布时间】:2015-12-19 16:29:34
【问题描述】:
我正在尝试发送电子邮件的密件抄送(Blind Carbon Copy)。
这是我的课:
class email{
function __construct(){
}
public function send($to, $from, $subject, $message){
$header = $this->nl('MIME-Version: 1.0') .
$this->nl('Content-Type: text/plain; charset=utf-8') .
$this->nl('X-Priority: 1') .
$this->nl('Importance: High') .
$this->nl('X-MSMail-Priority: High') .
$this->nl('Bcc: email1@email.com,email2@email.com') .
$this->nl('X-Mailer: PHP/' . phpversion());
return mail(
$to,
$subject,
$message,
$header,
'-f ' . $from
);
}
private static function nl($str){
return $str . "\r\n";
}
}
发送电子邮件时,收件人会收到电子邮件,但密件抄送收件人不会。
感谢 Dave 的解决方案:
class email{
function __construct(){
}
public function send($to, $from, $subject, $message){
$header = $this->nl('MIME-Version: 1.0') .
$this->nl('Content-Type: text/plain; charset=utf-8') .
$this->nl('X-Priority: 1') .
$this->nl('Importance: High') .
$this->nl('X-MSMail-Priority: High') .
$this->nl('BCC: rick <rick@email.com>; angela <angela@email.com>') .
$this->nl('X-Mailer: PHP/' . phpversion());
return mail(
$to,
$subject,
$message,
$header,
'-f ' . $from
);
}
private function nl($str){
return $str . "\r\n";
}
}
【问题讨论】:
-
用分号分隔电子邮件地址;不是逗号,
-
坚持我的 nl 函数没有返回。这可能是我的问题..让我试试
-
@Dave 哦,我以为你可以使用逗号
-
我一直用; (好吧,直到我换成使用 swiftmailer,因为它更好)也 Bcc 应该是 BCC 我相信电子邮件标题区分大小写。
-
@Dave 谢谢!有效。发布答案并让您成为最佳答案