PHP联系表单不会发送到AOL电子邮件

时间:2015-07-16 20:01:43

标签: php forms email

我已经根据我发现的一些开源代码改编了基本的PHP联系表单,该网站刚刚发布,现在我遇到了问题。主要是,表单似乎工作,但电子邮件没有到达我的客户的收件箱。

我使用他们的电子邮件作为收件人向我的客户发送了测试电子邮件,他们说他们还没有收到。但是,当我用自己的电子邮件替换它时,我的收件箱就好了。可能值得注意的是,客户端有一个AOL电子邮件地址 - 可能是AOL阻止了这个吗?我让他们检查了他们的垃圾邮件文件夹,他们仍然说他们看不到它。

我已经检查了我的代码问题,我很困惑这里发生了什么。我已经使用了一个类似的形式,对我所做的其他网站进行了调整,没有任何问题。

HTML表单:

<form name="contactform" method="post" action="mailer.php"      class="form-horizontal" role="form">
                        <div class="form-group">
                            <label for="inputName" class="col-lg-2 control-label">Name</label>
                            <div class="col-lg-10">
                                <input type="text" class="form-control" id="inputName" name="inputName" placeholder="Your Name">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="inputEmail1" class="col-lg-2 control-label">Email</label>
                            <div class="col-lg-10">
                                <input type="text" class="form-control" id="inputEmail" name="inputEmail" placeholder="Your Email">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="inputPhone" class="col-lg-2 control-label">Phone</label>
                            <div class="col-lg-10">
                                <input type="text" class="form-control" id="inputPhone" name="inputPhone" placeholder="Your Telephone Number">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="inputSubject" class="col-lg-2 control-label">Subject</label>
                            <div class="col-lg-10">
                                <input type="text" class="form-control" id="inputSubject" name="inputSubject" placeholder="Message Subject">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="inputPassword1" class="col-lg-2 control-label">Message</label>
                            <div class="col-lg-10">
                                <textarea class="form-control" rows="4" id="inputMessage" name="inputMessage" placeholder="Your Message..."></textarea>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-lg-offset-2 col-lg-10">
                                <button type="submit" class="btn btn-default">
                                    Send Message
                                </button>
                            </div>
                        </div>
                    </form>
                </div>

PHP文件:

<?php
/* Set e-mail recipient */
$myemail = "clientsemail@aol.com";

/* Check all form inputs using check_input function */
$name = check_input($_POST['inputName'], "Your Name");
$email = check_input($_POST['inputEmail'], "Your E-mail Address");
$phone = check_input($_POST['inputPhone'], "Your Telephone Number");
$subject = check_input($_POST['inputSubject'], "Message Subject");
$message = check_input($_POST['inputMessage'], "Your Message");

/* If e-mail is not valid show error message */
if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email))
{
show_error("Invalid e-mail address");
}
/* Let's prepare the message for the e-mail */

$subject = "Inquiry from Website";

$message = "

Someone has sent you a message using your website's contact form:

Name: $name
Email: $email
Telephone: $phone
Subject: $subject

Message:
$message

";

/* Send the message using mail() function */
mail($myemail, $subject, $message);

/* Redirect visitor to the thank you page */
header('Location:    http://www.theclientswebsite.com/confirmation.html');
exit();

/* Functions we used */
function check_input($data, $problem='')
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
if ($problem && strlen($data) == 0)
{
show_error($problem);
}
return $data;
}

function show_error($myError)
{
?>
<html>
<body>

<p>Please correct the following error:</p>
<strong><?php echo $myError; ?></strong>
<p>Hit the back button and try again</p>

</body>
</html>
<?php
exit();
}
?>

0 个答案:

没有答案