继续上一个有关PHP发送电子邮件包含HTML的问题,请帮助,也许我的代码有误:
$from = "Someone <[email protected]>";
$to = "Someone 1 <[email protected]>";
$subject = "Test Send Email";
$body = "<div>Test</div>";
$emaillist = "[email protected]";
$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 = "[email protected]";
$to = "[email protected]";
$headers = array(..other stuff.., 'To' => $to, ..rest of header stuff); // No Bcc header!
$recipients = $to.", ".$bcc;
$mail = $smtp->send($recipients, $headers, $message);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句