douan4106
douan4106
2014-04-17 10:21
浏览 28
已采纳

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

I am using PHP mail and trying to send BCC, but for some reason since I've added the lines with //ADDED NEW on it , it's just now sending any emails at all.

Here is the full code:

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

 $headers = "From: " . strip_tags('me@gmail.com') . "
";
 $headers .= "Reply-To: ". strip_tags('me@gmail.com') . "
";
 $headers .= "Bcc: $emailList
"; //ADDED NEW
 $headers .= "MIME-Version: 1.0
";
 $headers .= "Content-Type: text/html; charset=ISO-8859-1
"; 

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

Why is this not sending?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dongsisui7562
    dongsisui7562 2014-04-17 10:35
    已采纳

    Your problem,

    1. Set $bcc but in $headers does not using it
    2. Putting invalid argument into mail function.

    Try this

    $to = "me@gmail.com";
    $bccList = $row['recipients']; //ADDED NEW
    $subject = $row['subject'];
    $message = $row['text_body'];
    
    $headers = "From: " . strip_tags('me@gmail.com') . "
    ";
    $headers .= "Reply-To: ". strip_tags('me@gmail.com') . "
    ";
    $headers .= "Bcc: $bccList
    "; //ADDED NEW
    $headers .= "MIME-Version: 1.0
    ";
    $headers .= "Content-Type: text/html; charset=ISO-8859-1
    "; 
    
    mail($to, $subject, $message, $headers); // $bcc ADDED NEW
    
    点赞 评论
  • dsh12544
    dsh12544 2014-04-17 10:32

    There's no $bcc argument to the mail() function. It should be:

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

    The blind recipients will be retrieved from the Bcc header in $headers.

    点赞 评论

相关推荐