0

可能重复:
发送的邮件将进入垃圾邮件文件夹?

我有一个简单的 html 表单:

<div id="content">
<h2>Contact Us</h2>
<form name="contact" action="form-to-email4.php" method="post">
<label>Name: </label><input type="text" name="contact_name" /><br />
<label>Email Address: </label><input type="email" name="contact_email" /><br /><br />
<label>Message: </label><textarea name="message" rows="10" cols="50">
</textarea><br /><br />
<input type="submit" value="Submit"></form><br /><br />

</div>

和一个 PHP 脚本来处理和通过电子邮件发送信息

<?php
if($_SERVER['REQUEST_METHOD'] !== 'POST')
{
//This page should not be accessed directly. Need to submit the form.
echo "error; you need to submit the form!";
die;
}
$name = $_POST['contact_name']; $email = $_POST['contact_email']; $message = $_POST['message'];

if ($_POST['contact_name'] == "" || $_POST['contact_email'] == "" || $_POST['message'] == "" )     {
    echo "Please fill in all boxes.";}
else {

$email_from = 'chris569x@gmail.com';//<== update the email address
$email_subject = "Message from the SGU Website"; 
$email_body = "You have received a new message from the SGU website.\n". 
"Message From: $name \n".
"Email Address: $email \n".
"Message: $message \n";  
$to = "chris569x@gmail.com";//<== update the email address
$headers = "From: $email_from \r\n";
//Send the email!
mail($to,$email_subject,$email_body,$headers);
//done. redirect to thank-you page.
header('Location: thanks4.htm');
echo "<meta http-equiv='refresh' content='0; url=thanks4.htm'>";}
?> 

该脚本似乎可以正确处理。如果我尝试直接访问 PHP,我会收到消息,如果没有填写所有必填字段,我会收到消息,并且我会在脚本末尾重新定向到页面,但我从未收到任何电子邮件。我错过了什么?(我对此很陌生)

4

0 回答 0