【问题标题】:PHP BCC Email not workingPHP BCC电子邮件不起作用
【发布时间】:2014-05-01 07:27:48
【问题描述】:

从我关于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>");
}

运行良好,但是当密件抄送无法运行时。我在另一封电子邮件中看到密件抄送,没有收到。

【问题讨论】:

    标签: php


    【解决方案1】:

    试试:

    $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);
    

    参考:Sending multiple CC's and BCCs with PHP PEAR MAIL

    【讨论】:

      【解决方案2】:

      尝试像这样设置密件抄送

      $headers['Bcc'] = 'cc@example.com, bb@example.com, dd@ex.com';
      

      【讨论】:

        猜你喜欢
        • 2014-03-23
        • 1970-01-01
        • 2014-06-03
        • 2013-01-02
        • 2015-01-20
        • 1970-01-01
        • 2015-12-29
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多