2014-11-06 31 views
0

你好當我提交表單我得到經過多年的工作,網站聯繫表格突然停止工作?

警告的電流誤差:mail() [function.mail]:SMTP服務器響應:嘗試發送到非本地電子郵件時,503這個郵件服務器需要身份驗證地址。請檢查您的郵件客戶端設置,或與您的管理員聯繫,以驗證是否爲此服務器定義了域或地址。在../.../..../在線....

,直到我從mail()取出@符號我沒有得到這個錯誤消息,並且將其發送給我的電子郵件直到上個月左右。我不明白是什麼錯誤或什麼是錯,請幫助

<?php 
if(isset($_POST['email'])) { 



    // EDIT THE 2 LINES BELOW AS REQUIRED 

    $email_to = "[email protected]"; 

    $email_subject = "Subject...."; 





    function died($error) { 

     // your error code can go here 

     echo "We are very sorry, but there were error(s) found with the form you submitted. "; 

     echo "These errors appear below.<br /><br />"; 

     echo $error."<br /><br />"; 

     echo "Please go back and fix these errors.<br /><br />"; 

     die(); 

    } 



    // validation expected data exists 

    if(!isset($_POST['first_name']) || 

     !isset($_POST['last_name']) || 

     !isset($_POST['email']) || 

     !isset($_POST['telephone']) || 

     !isset($_POST['comments'])) { 

     died('We are sorry, but there appears to be a problem with the form you submitted.');  

    } 



    $first_name = $_POST['first_name']; // required 

    $last_name = $_POST['last_name']; // required 

    $email_from = $_POST['email']; // required 

    $telephone = $_POST['telephone']; // not required 

    $comments = $_POST['comments']; // required 



    $error_message = ""; 

    $email_exp = '/^[A-Za-z0-9._%-][email protected][A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; 

    if(!preg_match($email_exp,$email_from)) { 

    $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; 

    } 

    $string_exp = "/^[A-Za-z .'-]+$/"; 

    if(!preg_match($string_exp,$first_name)) { 

    $error_message .= 'The First Name you entered does not appear to be valid.<br />'; 

    } 

    if(!preg_match($string_exp,$last_name)) { 

    $error_message .= 'The Last Name you entered does not appear to be valid.<br />'; 

    } 

    if(strlen($comments) < 2) { 

    $error_message .= 'The Comments you entered do not appear to be valid.<br />'; 

    } 

    if(strlen($error_message) > 0) { 

    died($error_message); 

    } 

    $email_message = "Form details below.\n\n"; 



    function clean_string($string) { 

     $bad = array("content-type","bcc:","to:","cc:","href"); 

     return str_replace($bad,"",$string); 

    } 



    $email_message .= "First Name: ".clean_string($first_name)."\n"; 

    $email_message .= "Last Name: ".clean_string($last_name)."\n"; 

    $email_message .= "Email: ".clean_string($email_from)."\n"; 

    $email_message .= "Telephone: ".clean_string($telephone)."\n"; 

    $email_message .= "Comments: ".clean_string($comments)."\n"; 





// create email headers 

$headers = 'From: '.$email_from."\r\n". 

'Reply-To: '.$email_from."\r\n" . 

'X-Mailer: PHP/' . phpversion(); 

mail($email_to, $email_subject, $email_message, $headers); 

?> 



<!-- include your own success html here --> 



Thank you for contacting us. We will be in touch with you very soon. 



<?php 

} 
?> 
+0

聲音像SMTP服務器改變了它處理這些類型的請求的方式。 – rnevius 2014-11-06 09:28:48

+0

- 將smtp服務器設置更改爲允許從服務器的IP地址或 中繼 - 設置和使用「smtp身份驗證」,這將允許您發送到任何地方。 – 2014-11-06 09:29:42

+0

我將如何更改服務器設置以允許從服務器的ip中繼? – Bradley 2014-11-06 09:38:21

回答

5

這是因爲你使用的是PHP郵件()命令 - 其接着發送它通過在php.ini文件中列出的SMTP服務器。

但是,當它到達該服務器時,它會說「嗨,你沒有發送給我 - 你發送到外部地址,我不會讓你」。

你可以做兩件事情之一來解決此問題:
1.改變SMTP服務器設置爲允許從服務器的IP地址
2.建立&使用「SMTP認證」,這應該讓你發送中繼任何地方。這很可能會在smtp服務器上設置,因此您只需轉到Interspire電子郵件營銷大師設置頁面並在「SMTP服務器」部分中輸入相應的詳細信息。

來源:https://www.interspire.com/support/kb/questions/574/Warning%3A+mail()+%5Bfunction.mail%5D%3A+SMTP+server+response%3A+503+This+mail+server+requires+authentication+when+attempting+to+send+to+a+non-local+e-mail+address

+0

如何簡單地更改smtp服務器設置以允許從服務器的IP地址中繼 – Bradley 2014-11-06 10:08:10

+0

您將如何更改服務器設置? – 2014-11-13 10:53:42