在PHP中发送多个电子邮件

时间:2015-08-31 21:16:54

标签: php email

在这个php中有一些东西,在电子邮件中的回复电子邮件地址之后 - 我之后得到了一个Cc,它没有被发送到CC& BCC。这告诉我,我在这段代码的某个地方犯了一个错误,这可能是非常明显的。

// Create email 
$email_subject = "Subject";
$email_body = "You have received interest. \n\n".
              "Name: $name \nEmail: $email \n";
$headers = "From: 1-email@email.com\n";
$headers .= "Reply-To: $email";
$headers .= "Cc: 2-email@email.com\r\n";
$headers .= "Bcc: 3-email@email.com\r\n";

mail($to,$email_subject,$email_body,$headers); // Post message

2 个答案:

答案 0 :(得分:2)

尝试这样做:

// Create email 
$email_subject = "Subject";
$email_body = "You have received interest. \n\n".
          "Name: $name \nEmail: $email \n";
$headers = "From: 1-email@email.com\r\n";
$headers .= "Reply-To: $email\r\n";
$headers .= "Cc: 2-email@email.com\r\n";
$headers .= "Bcc: 3-email@email.com\r\n";

mail($to,$email_subject,$email_body,$headers); // Post message

答案 1 :(得分:2)

更新标题,使每行末尾都有\ r \ n。最后一行不需要它。

// Create email 
$email_subject = "Subject";
$email_body = "You have received interest. \n\n".
              "Name: $name \nEmail: $email \n";
$headers = "From: 1-email@email.com\r\n";
$headers .= "Reply-To: $email\r\n";
$headers .= "Cc: 2-email@email.com\r\n";
$headers .= "Bcc: 3-email@email.com";

mail($to,$email_subject,$email_body,$headers); // Post message