继续我关于PHP Sent Email Contains HTML的上一个问题,请帮助提出建议,也许我的代码出错:
$from = "Someone <someone@example.com>";
$to = "Someone 1 <someone1@example.com>";
$subject = "Test Send Email";
$body = "<div>Test</div>";
$emaillist = "sample@example.com";
$host = "mail.example.com";
$username = "someone";
$password = "blabla";
$headers = array(
'From' => $from,
'To' => $to,
'Subject' => $subject,
'Content-Type' => 'text/html; charset=UTF-8',
'Bcc' => $emaillist
);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'auth' => true,
'username' => $username,
'password' => $password));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail))
{
echo("<p>" . $mail->getMessage() . "</p>");
}
else
{
echo("<p>Message successfully sent!</p>");
}
运行良好,但是当Bcc无法运作时。我在另一封名为Bcc的电子邮件中看到,没有收到。
答案 0 :(得分:0)
尝试像这样设置Bcc
$headers['Bcc'] = 'cc@example.com, bb@example.com, dd@ex.com';
答案 1 :(得分:0)
尝试:
$bcc = "foo@example.com";
$to = "bar@example.com";
$headers = array(..other stuff.., 'To' => $to, ..rest of header stuff); // No Bcc header!
$recipients = $to.", ".$bcc;
$mail = $smtp->send($recipients, $headers, $message);