2012-08-10 40 views
0

我試圖讓這個聯繫表格工作,它似乎不能發送頭來說,它是從一個Gmail地址我覺得像雅虎地址也在混合那些沒有用的。這裏是代碼,這似乎是很重要的。如果主機很重要,我在Dreamhost上。請讓我知道。PHP郵件功能不從Gmail地址發送

if(!is_array($contact_information_type)) 
{ 
    $contact_information_type = Array(); 
} 

if($_POST){ 
    $contact_name = trim(stripslashes($_POST["contact_name"])); 
    $contact_company = trim(stripslashes($_POST["contact_company"])); 
    $contact_address1 = trim(stripslashes($_POST["contact_address1"])); 
    $contact_address2 = trim(stripslashes($_POST["contact_address2"])); 
    $contact_city = trim(stripslashes($_POST["contact_city"])); 
    $contact_state = trim(stripslashes($_POST["contact_state"])); 
    $contact_zip = trim(stripslashes($_POST["contact_zip"])); 
    $contact_country = trim(stripslashes($_POST["contact_country"])); 
    $contact_phone = trim(stripslashes($_POST["contact_phone"])); 
    $contact_fax = trim(stripslashes($_POST["contact_fax"])); 
    $contact_email = trim(stripslashes($_POST["contact_email"])); 
    $contact_comments = trim(stripslashes($_POST["contact_comments"])); 
if($contact_name == ""){ $errors_array[] = "Name is required."; } 
if($contact_company == ""){ $errors_array[] = "Company name is required."; } 
     if($contact_city == "") { $errors_array[] = "City is required."; } 

if($contact_state == ""){ $errors_array[] = "State is required."; } 




if($contact_country == "") { $errors_array[] = "Country is required.";} 
elseif($contact_country == "United States") 
{if($contact_zip != "" && !preg_match("/(^\d{5}$)|(^\d{5}-\d{4}$)/", $contact_zip)){  $errors_array[] = "Incorrect Zip. (e.g. 60660 or 60660-1234)"; };} 
elseif($contact_country == "Canada"){if($contact_zip != "" && !preg_match("/^[ABCEGHJ- NPRSTVXY]{1}[0-9]{1}[ABCEGHJ-NPRSTV-Z]{1}[ ]?[0-9]{1}[ABCEGHJ-NPRSTV-Z]{1}[0-9]{1}$/i",  $contact_zip)){ $errors_array[] = "Incorrect Zip. (e.g. M4C 1B5 or M4C1B5)"; };} 
                                                           else {;} 






    if($contact_phone == ""){ $errors_array[] = "Phone is required."; } 
    if($contact_phone != "" && !preg_match("/(^\d{3}-\d{3}-\d{4}$)| (^\d{10}$)/", $contact_phone)){ $errors_array[] = "Incorrect Phone. (e.g. 123-123-1234)"; } 
    if($contact_fax != "" && !preg_match("/(^\d{3}-\d{3}-\d{4}$)|(^\d{10}$)/", $contact_fax)){ $errors_array[] = "Incorrect Fax. (e.g. 123-123-1234)"; } 
    if($contact_email == ""){ $errors_array[] = "E-mail is required."; } 
    if($contact_email != "" && !preg_match("/^[a-zA-Z0-9_.-][email protected][a-zA-Z0-9-]+\. [a-zA-Z0-9-.]+$/", $contact_email)){ $errors_array[] = "Incorrect E-mail. (e.g. [email protected])"; } 
if($contact_comments == ""){ $errors_array[] = "Comments are required."; } 
    if(sizeof($errors_array) == 0){ 
     $contact_information_type = implode(", ",  $contact_information_type); 

$email_message = <<<MESSAGE 
The contact form on www.rotaryvalve.com has been filled out with the following information: 


Name: ${contact_name} 
Company: ${contact_company} 
Address 1: ${contact_address1} 
Address 2: ${contact_address2} 
City: ${contact_city} 
State: ${contact_state} 
Zip: ${contact_zip} 
Country: ${contact_country} 
Phone: ${contact_phone} 
Fax: ${contact_fax} 
E-mail: ${contact_email} 
Comments/Products of Interest: ${contact_comments} 
MESSAGE; 

     $email_adds = array("[email protected]", "[email protected]"); 
     $email_from = $contact_email; 
     $email_subject = "Customer Request/Comment"; 
     foreach($email_adds as $email_to){ 
      mail ($email_to, $email_subject, $email_message, "From: ".$email_from." <".$email_from.">"); 
     } 

基本上如果CONTACT_EMAIL填寫了表格(代碼不包含遺憾沒想到你會需要它,但讓我知道,如果你這樣做)是它似乎並沒有向它發送一個Gmail帳戶請幫我解決這個問題。

+0

它會去垃圾嗎? – Jrod 2012-08-10 19:40:37

+0

據我可以告訴它不是這就是爲什麼我要它去那裏2個不同的電子郵件地址。我已經檢查了他們的垃圾箱,沒有任何東西。 – user1590569 2012-08-10 20:07:25

回答

2

問題未發送或未收到。我很確定問題不在於發送的電子郵件,而是當接收者的電子郵件服務收到它時會發生什麼。它可能被歸類爲垃圾郵件,因爲他們可以看到它不是從Gmail郵件服務器發送的。

+0

真的不能告訴你它是哪個。我有一個完全相同的代碼在另一臺服務器上,所以我運行它,它給我發電子郵件,所以我想知道它是否比Dreamhost更重要,但我不確定我是否希望有人對此有一些建議 – user1590569 2012-08-10 20:09:55

+0

那麼,整個情況並不完全清楚,但我建議使用Michal Charemza的建議。 – hifkanotiks 2012-08-10 20:13:04

1

由於gmail.com域名上的SPF記錄很可能將電子郵件標記爲垃圾郵件,因此電子郵件可能會被接收服務器或客戶端歸類爲垃圾郵件。

然而,您可以通過在聯繫表單中輸入的電子郵件的'Reply-To'標題發送電子郵件。這將使電子郵件獲得過濾垃圾郵件過濾器的更好機會,並且如果收件人在其客戶端中點擊「回覆」按鈕,則電子郵件將默認發送到該地址。

相關問題