2010-11-01 82 views
1

我已經使用了這個PHP郵件腳本一段時間了,它給了我很好的幫助...我需要問幾個問題。PHP - 郵件表單內容 - 如何添加CC字段?

現在,它只是發送一封電子郵件給我發佈的信息。

那麼它只是回聲的用戶,如果它提交成功或沒有。

如何添加CC字段以向用戶發送有關下一步操作的某些指示?

感謝

if (isset($_POST['submit'])) { 

    if (!$_POST['name'] | !$_POST['email']) 
    { 
     echo"<div class='error'>Error<br />You did not fill in a required field, please review your form and correct the missing information.</div>"; 
    } 
    else 
    { 
     $name = $_POST['name']; 
     $email = $_POST['email']; 
     $email2 = $_POST['email2']; 
     $legal = $_POST['legal']; 
     $legal2 = $_POST['legal2']; 
     $address = $_POST['address']; 
     $address2 = $_POST['address2']; 
     $city = $_POST['city']; 
     $state = $_POST['state']; 
     $zip = $_POST['zip']; 
     $phone = $_POST['phone']; 
     $comments = $_POST['comments']; 



     $yoursite = "See Me Shine Models"; 
     $youremail = $email; 

     $subject = "Website Model Form"; 
     $message = "$name would like you to contact them about See Me Shine Models. 
      Contact PH: $phone 
      Email: $email 
      Email2: $email2 
      Legal: $legal 
      Legal2: $legal2 
      Address: $address 
      Address2: $address2 
      City: $city 
      State: $state 
      Zip: $zip 
      Phone: $phone 
      Comments: $comments"; 

     $email3 = "[email protected]"; 

     mail($email3, $subject, $message, "From: $email"); 

     echo"<div class='thankyou'>Thank you for contacting us,<br /> we will respond as soon as we can.</div>"; 

    } 
} 

回答

3

你需要指定報頭的第四個參數:

$xheaders = ""; 
$xheaders .= "From: Name-Here. <$email>\n"; 
$xheaders .= "X-Sender: <$email>\n"; 
$xheaders .= "X-Mailer: PHP\n"; // mailer 
$xheaders .= "X-Priority: 1\n"; //1 Urgent Message, 3 Normal 
$xheaders .= "Content-Type:text/html; charset=\"iso-8859-1\"\n"; 
$xheaders .= "Cc: [email protected]\n"; 
................. 


mail($email3, $subject, $message, $xheaders); 

或參閱本教程:

  • ​​
1
+0

我可以設置兩個mail()函數嗎?因此,而不是添加一個CC,我可以有兩個郵件功能,發送兩個不同的消息。那有意義嗎? – 2010-11-01 19:14:48

+0

是的,如果那是你想要做的。您只需在發送電子郵件之間更改$至字段。 – JasonS 2010-11-02 10:01:14