PHP邮件发送BCC无法正常工作

时间:2014-04-17 10:21:53

标签: php

我正在使用PHP邮件并尝试发送BCC,但出于某种原因,因为我已经在其上添加了// ADDED NEW的行,它现在只是发送任何电子邮件。

以下是完整代码:

 $to = "me@gmail.com";
 $bcc = $row['recipients']; //ADDED NEW
 $subject = $row['subject'];
 $message = $row['text_body'];

 $headers = "From: " . strip_tags('me@gmail.com') . "\r\n";
 $headers .= "Reply-To: ". strip_tags('me@gmail.com') . "\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 个答案:

答案 0 :(得分:1)

$bcc函数没有mail()个参数。它应该是:

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

将从Bcc中的$headers标题中检索盲人收件人。

答案 1 :(得分:1)

你的问题,

  1. 设置$bcc但在$headers中未使用
  2. 将无效参数放入mail函数。
  3. 试试这个

    $to = "me@gmail.com";
    $bccList = $row['recipients']; //ADDED NEW
    $subject = $row['subject'];
    $message = $row['text_body'];
    
    $headers = "From: " . strip_tags('me@gmail.com') . "\r\n";
    $headers .= "Reply-To: ". strip_tags('me@gmail.com') . "\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