php联系表单 - 电子邮件发送到垃圾邮件

时间:2016-02-13 12:20:10

标签: php html forms email

我有一个自定义构建的html联系表单添加到我的网站,集成了一个PHP表单(send-mail.php)。电子邮件会通过POST方法发送到指定的地址,如下面我粘贴的代码所示。

收到的电子邮件已发送到收件人收件箱中的垃圾邮件文件夹,因此暂时不会被注意到。收件人电子邮件客户端是AOL。

我是否可以对我的代码进行任何修改以确保所有电子邮件都到达收件箱?

我的HTML / PHP表单代码如下......

由于

<form action="send-mail.php" method="POST">
    <div class="form-group">     
        <label for="field_name" class="col-md-3 control-label">Name:</label>
        <div class="col-sm-8">     
            <input type="text" class="form-control" id="field_name" name="sender_name">     
        </div> 
    </div>

    <div class="form-group">
        <label for="field_email" class="col-md-3 control-label">Your e-mail:</label> 
        <div class="col-sm-8">    
            <input type="text" class="form-control" id="field_email" name="sender_email">
        </div>
    </div> 

    <div class="form-group">
        <label for="field_phone" class="col-md-3 control-label">Subject:</label> 
        <div class="col-sm-8">    
            <input type="text" class="form-control" id="field_phone" name="sender_phone">
        </div> 
    </div>

    <div class="form-group">
        <label for="field_message" class="col-md-3 control-label">Message:</label> 
        <div class="col-sm-8">    
            <textarea id="field_message" class="form-control" rows="14" name="sender_message"></textarea>
        </div>
    </div>

    <div class="form-group">
        <div class="col-sm-10 col-sm-offset-3">
            <input type="submit" class="btn btn-info" name="send_message" value="Send"> 
        </div>
    </div>
</form>

PHP表格......

<?php     
$mail_to       = 'hrmediation@aol.com'; 

$name          = $_POST['sender_name'];     
$mail_from     = $_POST['sender_email'];     
$phone         = $_POST['sender_phone'];     
$message       = $_POST['sender_message'];    

$subject       = 'Mediation East Sussex - Message from ' . $name;     

$body_message  = 'From: ' . $name . "\r\n";     
$body_message .= 'E-mail: ' . $mail_from . "\r\n";     
$body_message .= 'Phone: ' . $phone . "\r\n";     
$body_message .= 'Message: ' . $message;  

$headers       = 'From: ' . $mail_from . "\r\n";     
$headers      .= 'Reply-To: ' . $mail_from . "\r\n";     

$mail_sent     = mail($mail_to, $subject, $body_message, $headers);     

if ($mail_sent == true){ ?> <script language="javascript" type="text/javascript">         
    alert('Thank you for the message. We will contact you shortly.');        
    window.location = 'contact_us.html';        
    </script>
<?php } else { ?>     
    <script language="javascript" type="text/javascript">         
    alert('Message not sent. Please, notify the site administrator cjhill2002@hotmail.com');         
    window.location = 'contact-form.html';    
    </script>     
<?php     
} 
?>

15/2/16

感谢大家的建议,这里是电子邮件的源代码......对我来说没有任何意义,所以不确定它是否会对情况有所了解?

x-store-info:fHNTDlzCF8Nxw6HwcfGQy+S7Ax/lqLSmNphQ3OF+T9E=
Authentication-Results: hotmail.com; spf=pass (sender IP is 188.121.43.201; identity alignment result is fail and alignment mode is relaxed) smtp.mailfrom=noreply@secureserver.net; dkim=none (identity alignment result is pass and alignment mode is relaxed) header.d=gmail.com; x-hmca=none header.id=chdesigns2012@gmail.com
X-SID-PRA: chdesigns2012@gmail.com
X-AUTH-Result: NONE
X-SID-Result: NONE
X-Message-Status: n:n
X-Message-Delivery: Vj0xLjE7dXM9MDtsPTE7YT0wO0Q9MjtHRD0yO1NDTD00
X-Message-Info: 11chDOWqoTnMEo64LnD9BVKUHaeNkNd7wqUn23A//RySeublZ9ECBuN7qsUqH2ObwCexkObtS6T8EqV/zkipCDY1/OTveK4H1z4BpvwX2tuCS8rNmpjZMDxBREUjMU0UJIRnInCreID+tLPTeKK44fWrRgZWc9ufctrUNTnV8Xar+gGDJqE8uFIqpCSbx7mU2pnTxuTdWS9VCs1CFnCtie0kPaKc82I7+p4Lua/bHQUfxSunKCTOZA==
Received: from n1nlsmtp01.shr.prod.ams1.secureserver.net ([188.121.43.201]) by SNT004-MC4F6.hotmail.com over TLS secured channel with Microsoft SMTPSVC(7.5.7601.23143);
     Mon, 15 Feb 2016 14:04:08 -0800
Received: from N1NWVPWEB009.ams1.gdhosting.gdg ([188.121.43.18])
    by : HOSTING RELAY : with SMTP
    id VRFWanlLzCZ2tVRFWalT7k; Mon, 15 Feb 2016 15:04:06 -0700
Date: Mon, 15 Feb 2016 22:04:06 +0000
Subject: Mediation East Sussex - Message from TEST
To: cjhill2002@hotmail.com
X-PHP-Originating-Script: 0:send-mail.php
From: chdesigns2012@gmail.com
Reply-To: chdesigns2012@gmail.com
X-CMAE-Envelope: MS4wfEfgYgSB0p6T/jtVzFhR4YhqJR1+NJ3wqDBvo5gi11ERgY7Zu9YfE8WzIt3djg1qZ+dNeRfMjInsUYTaA5U1Zza6jpAxWbhF4EV+vG0rR8+vGhQxE9QP
 5L3ZY5wWG3pDpu/+YJAlkniqNIXjDeZRscz95Ks5cNapMVwUxl0MsyZJED+TxWS3Ppth2Me6m5WlMRi93Eel7bupYULKKrem640=
Return-Path: noreply@secureserver.net
Message-ID: <SNT004-MC4F6dOgl4rh0035c637@SNT004-MC4F6.hotmail.com>
X-OriginalArrivalTime: 15 Feb 2016 22:04:08.0195 (UTC) FILETIME=[CAE77D30:01D1683C]

From: TEST
E-mail: chdesigns2012@gmail.com
Phone: test
Message: test

1 个答案:

答案 0 :(得分:1)

垃圾邮件不依赖于100%代码。 20%取决于代码,80%取决于SMTP服务器声誉(您可以从https://www.senderscore.org/获得此分数。)

因此,代码和垃圾邮件之间不是直接关系。

但是,您可以按照一般规则改进电子邮件的内容 http://www.inc.com/geoffrey-james/how-to-avoid-a-spam-filter-5-rules.html http://mailchimp.com/resources/guides/how-to-avoid-spam-filters/html/

根据我的经验,您可以添加所有这些规则,也可以将您的电子邮件发送到垃圾邮件收件箱。

我希望它适合你。