2014-04-17 34 views
-1

我正在使用PHP郵件並嘗試發送密件抄送,但由於某些原因,因爲我添加了// ADDED NEW行,它現在只是發送任何電子郵件。PHP郵件發送BCC不是wordking

下面是完整的代碼:

$to = "[email protected]"; 
$bcc = $row['recipients']; //ADDED NEW 
$subject = $row['subject']; 
$message = $row['text_body']; 

$headers = "From: " . strip_tags('[email protected]') . "\r\n"; 
$headers .= "Reply-To: ". strip_tags('[email protected]') . "\r\n"; 
$headers .= "Bcc: $emailList\r\n"; //ADDED NEW 
$headers .= "MIME-Version: 1.0\r\n"; 
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; 

mail($to, $bcc, $subject, $message, $headers); // $bcc ADDED NEW 

這是爲什麼不發?

+2

的'郵件()'函數不具有'bcc'說法。閱讀[文檔](http://us3.php.net/manual/en/function.mail.php) – Barmar

+0

你在哪裏設置'$ emailList'? – Barmar

+0

@TomaszKowalczyk答案中沒有PHP代碼,我不明白它有什麼幫助。 – Barmar

回答

1

你的問題,

  1. $bcc$headers不使用它
  2. 把無效的參數爲mail功能。

試試這個

$to = "[email protected]"; 
$bccList = $row['recipients']; //ADDED NEW 
$subject = $row['subject']; 
$message = $row['text_body']; 

$headers = "From: " . strip_tags('[email protected]') . "\r\n"; 
$headers .= "Reply-To: ". strip_tags('[email protected]') . "\r\n"; 
$headers .= "Bcc: $bccList\r\n"; //ADDED NEW 
$headers .= "MIME-Version: 1.0\r\n"; 
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; 

mail($to, $subject, $message, $headers); // $bcc ADDED NEW 
1

沒有$bcc參數mail()函數。它應該是:

mail($to, $subject, $message, $headers); 

盲收件人將從Bcc頭在$headers進行檢索。