我有一個腳本從網站上的表單發送電子郵件。我知道代碼很好 - 我以前曾用兩家不同的託管公司進行過測試。這次我在一個實際的服務器上使用它,而不是託管公司。基本上用戶填寫表單,點擊提交併獲取消息已發送的確認頁面。唯一的不是電子郵件。下面是該腳本:PHP電子郵件腳本不發送電子郵件
$nickname = $_REQUEST['nickname'] ;
$email = $_REQUEST['email'] ;
$tel = $_REQUEST['tel'] ;
$comp = $_REQUEST['comp'] ;
$message = $_REQUEST['message'] ;
// Let's check if all fields are filled in!
if(empty($nickname) || empty($email) || empty($comp))
{
$error = "All of the required fields have not been completed, <a href=\"javascript:history.go(-1)\">please click here to go back.</a>";
}
else
{
$content= "$nickname has sent you an e-mail from XXX
Query:
$message
You can contact $nickname via Email: $email. <br />Other relevant details of individual: <br />Telephone Number: $tel <br />Company: $comp";
mail("[email protected]", "Query", $content, "From: $email"); //first thing has to be address it is going to, then what the subject of the mail should be, the content and a from address which will be the query submitter.
echo "<h2>$nickname</h2><br></br>
Your query has been succesfully sent. <br></br><br></br>
We will deal with this query and be in touch as soon as possible.<br></br><br></br><br></br>
The contact details you submitted are: <br></br><br></br>
<strong>Email:</strong> $email<br></br><br></br>
<strong>Phone:</strong> $tel<br></br><br></br>
<strong>Company:</strong> $comp<br></br><br></br>
<a //href=\"javascript:history.go(-1)\"> Click here to return to the contact page.</a></br>";
};
?>
我不知道這是否事項要麼但直到最近,PHP不會在服務器上運行,並給了一個HTTP錯誤405錯誤,說動詞是不允許的。這已經解決了。
如果代碼適用於其他網站託管服務很好,我會建議你看看SMTP或郵寄發送服務設置。嘗試做一個簡單的郵件()沒有其他邏輯或代碼作爲一個理智的測試。 – Extrakun 2010-09-16 12:49:01
我有幾個有關您的電子郵件問題的問題。你的服務器上是否安裝了Parellels Plesk?你有一臺SMTP服務器在服務器上運行和設置嗎?您的服務器是基於Linux還是Windows?這是一個Linux安裝程序:http://articles.sitepoint.com/article/advanced-email-php這裏是一個Windows安裝程序:http://www.geeklog.net/faqman/index.php?op=view&t= 19 – 2010-09-16 12:51:42
我對服務器不太熟悉。我沒有設置這個。我探討了一下,並且我在IIS管理器中看到SMTP虛擬服務器已停止,所以我想知道這是否是我的問題? – 109221793 2010-09-16 12:57:19