2015-07-12 81 views
0

需要發送密件抄送副本到[email protected] 不熟悉PHP,我錯過了一些東西。用PHP發送密件抄送

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

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

$to = '[email protected]'; // 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: [email protected]\n"; 
$headers .= "Reply-To: $email2"; 
$headers .= "Bcc: [email protected]" . "\r\n"; 

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

是'$ EMAIL_SUBJECT =「從網站消息;'故意的嗎? –

+1

可能與以下內容重複:http://stackoverflow.com/questions/9525415/php-email-sending-bcc你確定錯過的是一個結束符「在分號前:$ email_subject =」來自網站的消息; – wgitscht

+0

我讀過儘管在這裏發表了關於這個主題的文章,但似乎沒有人直接回答這個問題;用我的基本un無論如何。在結束時添加「,謝謝。 –

回答

1

在任何$標題行的端固定與結束 「\ r \ n」 個

$headers = "From: [email protected]\r\n"; 
$headers .= "Reply-To: $email2\r\n"; 
$headers .= "Bcc: [email protected]\r\n"; 

現在就來試試

+0

工作。謝謝。 –

相關問題