1

I have a custom built html contact form added to a website of mine that integrates with a php form (send-mail.php). The emails get sent to the designated address via the POST method as you can see in the code i pasted below.

The emails that have been received have been sent to the spam folder in the recipients inbox, thus go un-noticed for a while. The recipient email client is AOL.

Are there any amendments that i can make to my code to ensure all emails arrive in the inbox?

My code for HTML/PHP forms are below...

Thanks

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

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

Thanks for the suggestions guys, here is the source code for the email...means nothing to me so not sure if it sheds any light on the situation?

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
Chris
  • 199
  • 2
  • 6
  • 19
  • 1
    There is no sense in _guessing_ what the issue might be. You have to understand how spam filters work. Usually they add the reason of their judgement to the headers contained in the email. So get hold of such an email and take a look into the header. Typically you will see a set of rules and scored points indicating precisely _why_ the message is considered spam. Note: you need the email, not a copy of the body of the email. – arkascha Feb 13 '16 at 12:24
  • ok so where exactly in the emal can i find these rules and points? I'll need to view it from the recipients email client then, they can't forward the email on to me? – Chris Feb 13 '16 at 12:31
  • Ask them to send the original as attachment, that usually preserves all headers. Then open that email (or the full email you received) with a normal text editor. The headers precede the messages content, separated by an empty line. They contain routing information from server to server, some control headers like encoding, subject, to and from field and hopefully also some markers of the spam filter. – arkascha Feb 13 '16 at 12:34
  • If that does not work, then ask them to "open the email source code" (right click context menu) and print the resulting text. – arkascha Feb 13 '16 at 12:35
  • I wouldn't set the 'From' line, but do set the 'Reply-to' if you need the convenience. As the mail is most likely from your web server, email recipients might do reverse lookups, and it looks as if you are spoofing mail. – Progrock Feb 13 '16 at 13:37
  • Also be careful with respect to 'email injection'. – Progrock Feb 13 '16 at 13:38
  • thanks for all the suggestions folks. Below is the source code for the emai. Not sure what to make of it, doesnt seem to provide any clues... – Chris Feb 15 '16 at 22:14

1 Answers1

1

Spam is not a 100% code dependent. 20% depends on the code and 80% depends on SMTP server reputation (you can get this score from https://www.senderscore.org/ ).

So is not a direct relation between code and spam.

However you can improve the content of your email following some general rules 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/

In my experience, you can add all those rules and also your emails could arrive to spam inbox.

I hope it fits for you.

Claudio
  • 296
  • 2
  • 6
  • I would not consider this an answer, it is more like a general advice, so it should have been a comment... – arkascha Feb 13 '16 at 12:36
  • ok. My intention was highlight that not all is related to the code in SPAM´s world. Email servers owers @internet change the rules all the time in order to fine tune the SPAM detection process. So it is impossible (virtually) create a code without spam issues. – Claudio Feb 15 '16 at 21:40
  • Which is undoubtedly true, but does not change the fact that this does not answer the OPs question, does it? But all fine :-) – arkascha Feb 16 '16 at 08:18