PHP:我无法向多个收件人发送电子邮件

时间:2013-03-30 14:11:57

标签: php email

我已经检查过php手册,但仍无法让我的脚本工作

如果我删除BCC行,邮件会转到$ to1但是有了BCC行,它无处可去

这是代码:

// email stuff
$to1 = "address1@mail.com";
$to2 = "address2@mail.com";
$from = "noreply@mail.com"; 
$subject = "Subject"; 
$message = "message";

// a random hash will be necessary to send mixed content
$separator = md5(time());

// carriage return type (we use a PHP end of line constant)
$eol = PHP_EOL;

// main header
$headers  = "To: ".$to1.$eol;
$headers .= "From: ".$from.$eol;
$headers .= "Bcc: ".$to2.$eol;
$headers .= "MIME-Version: 1.0".$eol; 
$headers .= "Content-Type: multipart/mixed; boundary=\"".$separator."\"".$eol;

// no more headers after this, we start the body! //

$body = "--".$separator.$eol;
$body .= "Content-Transfer-Encoding: 7bit".$eol;
$body .= "This is a MIME encoded message.".$eol;

// message
$body .= "--".$separator.$eol;
$body .= "Content-Type: text/html; charset=\"iso-8859-1\"".$eol;
$body .= "Content-Transfer-Encoding: 8bit".$eol;
$body .= $message.$eol;

// send message
mail($to1, $subject, $body, $headers);

如果有人有想法,非常感谢

0 个答案:

没有答案