duanshan3065 2015-07-16 20:01
浏览 27

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

I've made a basic PHP contact form adapted from some open source code I found, the site just was published, and now I'm having an issue. Mainly, the form seems to work but the email is not arriving in my client's inbox.

I sent a test email to my client using their email as the recipient, and they say they haven't received it. However, when I substitute my own email it comes to my inbox just fine. It might be worth noting that the client has an AOL email address - could it be that AOL blocks this? I've had them check their spam folder, they still say they can't see it.

I've checked my code for issues, and I'm baffled what is going on here. I've used a similar form with adjustments for other sites I've made with no issues.

The HTML form:

<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>

The PHP file:

<?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条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
    • ¥50 我撰写的python爬虫爬不了 要爬的网址有反爬机制
    • ¥15 Centos / PETSc / PETGEM
    • ¥15 centos7.9 IPv6端口telnet和端口监控问题
    • ¥120 计算机网络的新校区组网设计
    • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
    • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
    • ¥20 海浪数据 南海地区海况数据,波浪数据
    • ¥20 软件测试决策法疑问求解答
    • ¥15 win11 23H2删除推荐的项目,支持注册表等