[英]PHPMailer not sending CC or BCC
我已經測試了以下代碼幾個小時了。 電子郵件將發送到通過$mail->AddAddress()
添加的地址,並在收到的電子郵件中說明cc,但是cced的人沒有收到電子郵件。 我到處尋找,無法找到解決方案的原因。 我已經運行了測試,並且正確地將所有變量提交給此代碼。
我的服務器正在運行Linux Red Hat
我的代碼:
require_once('../smtp/class.phpmailer.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
$mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch
$mail->IsSMTP(); // telling the class to use SMTP
try {
$mail->SMTPDebug = 0; // enables SMTP debug information (for testing)
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "tls"; // sets the prefix to the server
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = $port; // set the SMTP port for the GMAIL server 465 or 587
$mail->Username = $username; // GMAIL username
$mail->Password = $password; // GMAIL password
// Add each email address
foreach($emailTo as $email){ $mail->AddAddress(trim($email)); }
if($cc!=''){ foreach($cc as $email){ $mail->AddCC(trim($email)); } }
if($bcc!=''){ foreach($bcc as $email){ $mail->AddBCC(trim($email)); } }
$mail->SetFrom($emailFrom, $emailName);
$mail->AddReplyTo($emailFrom, $emailName);
$mail->Subject = $subject;
$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically
$mail->MsgHTML($content);
// $mail->AddAttachment('images/phpmailer.gif'); // attachment
// $mail->AddAttachment('images/phpmailer_mini.gif'); // attachment
$mail->Send();
echo'1';exit();
} catch (phpmailerException $e) {
echo $e->errorMessage(); //Pretty error messages from PHPMailer
} catch (Exception $e) {
echo $e->getMessage(); //Boring error messages from anything else!
}
老問題,但我最終在這里尋找答案。 剛才在其他地方了解到,這些函數AddCC和AddBCC僅適用於win32 SMTP
嘗試使用:
$mail->addCustomHeader("BCC: mybccaddress@mydomain.com");
請參閱http://phpmailer.worxware.com/?pg=methods
希望這有助於某人,歡呼!
$address = "xxxxx@gmail.com";
$mail->AddAddress($address, "technical support");
$address = "yyyyyy@gmail.com";
$mail->AddAddress($address, "other");
$addressCC = "zzzzzz@gmail.com";
$mail->AddCC($addressCC, 'cc account');
$addressCC = "bcc@gmail.com";
$mail->AddBCC($addressCC, 'bcc account');
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.