我有一個PHP代碼發送電子郵件,cc &密送。PHP發送電子郵件BCC&CC使用SMTP
在這種情況下,cc不起作用。 我測試了它,並在我的電子郵件中看到沒有cc電子郵件。 (BCC電子郵件進行加工)
這裏是我的代碼:
require_once "Mail.php";
$from = "WEBAPPS <[email protected]>";
$subject = "Calibration will be expiring!";
$host = 'smtp.office365.com';
$port = '587';
$username = '[email protected]';
$password = 'w00ew?';
$to = "[email protected]";
$cc = "[email protected]";
$bcc = "[email protected]";
$body = "aa";
$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>");
}
爲什麼CC不工作?以及如何解決它?
真棒和酷,測試和完美工作。乾杯安德烈和謝謝 –