用PHP发送BCC

时间:2015-07-12 20:03:13

标签: php

需要将BCC副本发送到user2@gmail.com 不熟悉PHP,我错过了什么。

<?php   
if(empty($_POST['name2']) || empty($_POST['email2']) || empty($_POST['message2']))
{
    return false;
}

$name2 = $_POST['name2'];
$email2 = $_POST['email2'];
$message2 = $_POST['message2'];

$to = 'user1@gmail.com'; // Email submissions are sent to this email

// Create email 
$email_subject = "Message from Website;
$email_body = "You have received a new message. \n\n".
              "Name2: $name2 \nEmail2: $email2 \nMessage2: $message2 \n";
$headers = "From: user1@gmail.com\n";
$headers .= "Reply-To: $email2";
$headers .= "Bcc: user2@gmail.com" . "\r\n";

mail($to,$email_subject,$email_body,$headers); // Post message
return true;            
?>

1 个答案:

答案 0 :(得分:1)

在以“\ r \ n”

结尾的任何$标题行修复的末尾
$headers = "From: user1@gmail.com\r\n";
$headers .= "Reply-To: $email2\r\n";
$headers .= "Bcc: user2@gmail.com\r\n";

立即尝试