PHP电子邮件发送到,cc和密送

时间:2017-08-03 08:24:54

标签: php email

我有PHP电子邮件

$host = 'smtp.office365.com';
$port = '587';
$username = 'donotreply@test.com';
$password = 'sew004?';

$headers = array(
    'Port'          => $port,
    'From'          => $from,
    'To'            => $to,
    'Subject'       => $subject,
    'Content-Type'  => 'text/html; charset=UTF-8'
);

$recipients = $to.", ".$cc.", ".$bcc;

$smtp = Mail::factory('smtp',
    array ('host' => $host,
    'auth' => true,
    'username' => $username,
    'password' => $password));

    $mail = $smtp->send($recipients, $headers, $body);

    if (PEAR::isError($mail)) {
         echo("<p>" . $mail->getMessage() . "</p>");
    } else {
         echo("<p>Message successfully sent!</p>");
    }

如果我使用此功能,现在无法发送它:

$recipients = $to.", ".$cc.", ".$bcc;

但如果我删除其中一个:

$recipients = $to.", ".$cc;

它可以完美无缺。

但现在我想,我可以发送电子邮件给cc,bcc。

0 个答案:

没有答案