我一直在嘗試使用PHP的郵件()函數,但似乎無法得到郵件發送到我的電子郵件地址時,我測試聯繫人窗體。它只是進入一個白色的屏幕,沒有更多的..它甚至沒有顯示下面的成功消息。PHP郵件發送簡單的聯繫表格
這是PHP:
<?php
if(isset($_POST['submit'])) {
$name = $_POST['name'];
$address = $_POST['address'];
$number = $_POST['number'];
$email = $_POST['email'];
$message = $_POST['message'];
$subject = 'Message from Reef website';
$to = '[email protected]';
if (empty($name) || empty($address) || empty($number) || empty($email) || empty($subject) || empty($message)) {
if (empty($name))
$error['name'] = "Please enter your Full Name";
if (empty($name))
$error['address'] = "Please enter your address";
if (empty($name))
$error['number'] = "Please enter a contact number";
if (empty($email))
$error['email'] = "Please enter a valid Email Address";
if (empty($message))
$error['message'] = "Please write a message, enquiries or other concerns above";
}
else { //if not empty
$headers="From: {$email}\r\nReply-To: {$email}";
mail($to,$subject,$message,$headers);
$success = "Thank you! You're email has been sent.";
}
}
?>
這是我的HTML表單:
<form method="POST" action="mailer.php">
<table border="1">
<tr>
<td><label for="name" class="g">Name</label></td>
<td><input id="name" name="name" type="text" required autofocus></td>
</tr>
<tr>
<td><label for="address" class="g">Address</label></td>
<td><textarea rows="3" id="address" name="address" cols="50"></textarea></td>
</tr>
<tr>
<td><label for="number" class="g">Contact number</label></td>
<td><input id="number" name="text" type="text" required autofocus></td>
</tr>
<tr>
<td><label for="email" class="g">Email</label></td>
<td><input id="email" name="email" type="text" placeholder="[email protected]" required autofocus></td>
</tr>
<tr>
<td><label for="message" class="g">Enquiry</label></td>
<td><textarea rows="3" id="message" name="message" cols="50"></textarea></td>
</tr>
</table>
<input type="submit" value="Submit" name="submit">
</form>
任何人都可以看到缺少了什麼?看着其他類似的問題,這些都是我的,但他們說,他們的工作。
那是因爲你沒有任何呼應的error..echo的他們,你就會知道什麼是錯誤.. – 2013-04-22 11:37:35
使用的error_reporting(E_ALL);在第一行,並給我們的錯誤 – Robert 2013-04-22 11:39:54