我曾经使用过godaddy的形式但是停止了工作。他们说"他们正在研究它"。所以现在我尝试自己的。但没有运气。它不发送。我究竟做错了什么?
这是我的HTML
<form action="Test3.php" method="post">
<input type="hidden" name="Subject" value="Submission from Website" />
<input type="hidden" name="redirect" value="thankyou.htm" />
<table style="width: 100%">
<tr>
<td style="width: 68px">Name:</td>
<td><input name="Name" type="text" size="40" style="background-color: #FFFF99" />
<span class="style1">(required)</span></td>
</tr>
<tr>
<td style="width: 68px">Email:</td>
<td><input name="Email" type="text" size="40" style="background-color: #FFFF99" />
<span class="style1">(required)</span></td>
</tr>
<tr>
<td style="width: 68px">Phone:</td>
<td><input name="Phone" type="text" size="40" style="background-color: #FFFF99" />
<span class="style1">(required)</span></td>
</tr>
</table>
<p><strong>Question:</strong></p>
<p><textarea name="Message" rows="4" cols="50"></textarea></p>
<div><input type="submit" value="Submit"/></div>
<input type="hidden" name="form_order" value="default"/>
<input type="hidden" name="form_delivery" value="default"/>
<input type="hidden" name="form_format" value="html"/>
</form>
这是PHP
if(isset($ _ POST [&#39; submit&#39;])){ $ error =&#34;&#34;;
if (!empty($_POST['name'])) {
$name = $_POST['name'];
} else {
$error .= "You didn't type in your name. <br />";
}
if (!empty($_POST['email'])) {
$email = $_POST['email'];
if (!preg_match("/^[a-z0-9]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i", $email)){
$error .= "The e-mail address you entered is not valid. <br/>";
}
} else {
$error .= "You didn't type in an e-mail address. <br />";
}
if (!empty($_POST['phone'])) {
$name = $_POST['phone'];
} else {
$error .= "You didn't enter your phone. <br />";
}
if (!empty($_POST['message'])) {
$message = $_POST['message'];
} else {
$error .= "You didn't type in a message. <br />";
}
if (empty($error)) {
$from = 'From: ' . $fname . ' <' . $email . '>';
$to = "email@domain.com";
$subject = "New contact form message";
$content = $name . " has sent you a message. \nEmail: $email \nPhone: $phone \nMessage: \n" . $message;
mail($to,$subject,$content,$from);
header('Location: thankyou.htm');
}
}
&GT;
这个php有效。对其他php不起作用没有任何意义。
<?php
$ToEmail = 'email@domain.com';
$EmailSubject = 'TEST contact form';
$mailheader = "From: ".$_POST["email"]."\r\n";
$mailheader .= "Reply-To: ".$_POST["email"]."\r\n";
$mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n";
$MESSAGE_BODY = "Name: ".$_POST["Name"]."<br/>";
$MESSAGE_BODY .= "Email: ".$_POST["Email"]."<br/>";
$MESSAGE_BODY .= "Message: ".nl2br($_POST["Message"])."";
mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure");
header('Location: thankyou.htm');
exit();
?>