我有一個利用PHP Mail()函數的HTML表單。我使用的SMTP服務器是localhost,不需要驗證。PHP不會發送HTML郵件
<form action="../../Scripts/fused.php" method="POST"><p>Name</p> <input type="text" name="name">
<p>Email</p> <input type="text" name="email">
<p>Phone</p> <input type="text" name="phone">
<p>Request Phone Call:</p>
Yes:<input type="checkbox" value="Yes" name="call"><br />
No:<input type="checkbox" value="No" name="call"><br />
<p>Website</p> <input type="text" name="website">
<p>Message</p><textarea name="message" rows="6" cols="25"></textarea><br />
<input type="submit" value="Send"><input type="reset" value="Clear">
</form>
這裏是php文件:
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$call = $_POST['call'];
$website = $_POST['website'];
$message = $_POST['message'];
$formcontent = 'From: $name \n Phone: $phone \n Call Back: $call \n Website: $website \n Message: $message';
$recipient = '[email protected]';
$subject = 'Fused Enterprises Contact Form';
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$headers .= 'From: <[email protected]>' . "\r\n";
$headers .= 'Cc: [email protected]' . "\r\n";
mail($recipient, $subject, $formcontent, $headers) or die("Error!");
echo "Thank You, the form has been submitted. Someone from the Team will contact you shortly." . " -" . "<a href='/Home/' style='text-decoration:none; color:#1e90ff;'> Return Home</a>";
?>
我一定要實現PEAR郵件?我也試圖實現,並且我沒有收到電子郵件。我不知道它是否失敗。腳本運行,我得到echo
,但我從來沒有收到電子郵件。它沒有去垃圾郵件文件夾。
該網站託管(與此腳本一起)在example.com
下,但電子郵件使用本地主機與smtp服務器mail.example.com
。它們託管在同一臺服務器上。域名的差異可能是一個問題?
當你說「不會發送」你的意思是它給人的錯誤,或者您沒有收到該電子郵件?你有檢查過你的垃圾郵件文件夾嗎? – 2013-03-05 19:40:17
我沒有收到電子郵件。我沒有任何跡象表明它是否失敗。我也檢查過垃圾郵件文件夾,但它會發送兩封不同的電子郵件,但都未收到。 – user1453549 2013-03-05 19:51:07
檢查您的郵件日誌。 – Sammitch 2013-03-05 21:11:28