0
我已經託管了該網站,並且已經創建了表單和PHP,但我無法獲取表單來實際發送電子郵件。我很確定我正確地列出了所有的變量。表單確實提交,在用戶提交某些內容後彈出提示並且表單未顯示,但我從未收到該電子郵件。這裏是我的代碼:無法讓PHP郵件()正常工作
<?php
if (isset($_REQUEST['email']) && isset($_REQUEST['fullname'])) {
//Email information
$admin_email = 'myemail.hotmail.co.uk';
$fullname = $_REQUEST['fullname'];
$email = $_REQUEST['email'];
$phone = $_REQUEST['phone'];
$followup = $_REQUEST['followup'];
$comment = $_REQUEST['comment'];
//send email
mail($admin_email, $fullname, $comment, 'From: ' . $email . 'Phone: ' . $phone . 'Follow up? ' . $followup);
//Email response
$contactThanks = "Thank you for contacting us!";
echo "<script type='text/javascript'>alert('$contactThanks');</script>";
}
//if 'email' variable is not filled out, display the form
else {
?>
<form action='<?php echo $_SERVER['PHP_SELF']; ?>' method='post'>
<table class='contactForm'>
<tr>
<td><label for='fullname'>*Full Name:</label></td>
<td><input type='text' name='fullname' id='fullname' /></td>
</tr>
<tr>
<td><label for='email'>*Email:</label></td>
<td><input type='text' name='email' id='email' /></td>
</tr>
<tr>
<td><label for='phone'>Phone:</label></td>
<td><input type='tel' name='phone' id='phone' /></td>
</tr>
<tr>
<td><label for='followup'>Follow Up:</label></td>
<td><input type='text' name='followup' id='followup' /></td>
</tr>
<tr>
<td><label for='comments'>Comments:</label></td>
<td><textarea type='text' name='comments' id='comments'></textarea></td>
</tr>
<tr>
<td id='inputButtons' colspan='2'>
<input type='submit' value='Submit' id='submit'/>
<input type='reset' value='Reset' id='reset'/>
</td>
</tr>
</table>
</form>
<?php
}
?>
任何人都可以看到爲什麼這是行不通的?謝謝。
提供您要發送的輸入信息..管理員電子郵件格式錯誤$ admin_email ='myemail.hotmail.co.uk'; – 2014-10-17 08:45:33
是啊對不起,這是一個枯燥的工作,我刪除了我的實際電子郵件與替代郵政,在我的代碼中它的格式正確。 – 2014-10-17 09:03:40