0

I'm trying to send my newsletter from a php file to some contacts from a database. But when I'm sending the mail to a Google Mail account, the mail is going to the spam filters and not in Inbox. If I send the mail to a Yahoo Mail account, it's working perfectly.

I tryed a lot of possibilities, and I wrote the code necessarry to be a nice e-mail but no result for G-Mail. If you can give me an idea to make my php function not so spammy, I would be grateful. Thanks in advance.

The php code for this is:

function spamcheck($field) {
    $field=filter_var($field, FILTER_SANITIZE_EMAIL);
    if(filter_var($field, FILTER_VALIDATE_EMAIL)) {
        return TRUE;
    } else {
        return FALSE;
    }
}

if(isset($_REQUEST) && isset($_POST['check'])) {
    if(!empty($_POST['check'])) {
        $mailcheck = spamcheck($_POST["from"]);                 
        foreach($_POST['check'] as $checkB) {
            if($mailcheck==FALSE) {
                echo "Invalid Imputs!";
            } else {
                $to = $checkB;
                $headers = "Reply-To: Caron Chiropractic ".$_POST['from']."\r\n";
                $headers .= "Return-Path: Caron Chiropractic ".$_POST['from']."\r\n";
                $headers .= "From: Caron Chiropractic ".$_POST['from']."\r\n";
                $headers .= "Organization: Caron Chiropractor\r\n";
                $headers .= "MIME-Version: 1.0\r\n";
                $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
                $headers .= "X-Priority: 3\r\n";
                $headers .= "X-Mailer: PHP/" . phpversion();

                $message = '<table style="margin: auto; width: 500px; font-family: sans-serif, Verdana, Arial, Helvetica, sans-serif; text-align: center; border-width: 2px; border-color: #999999; box-shadow: 0 0 10px gray; background: #F0F0F0;">
                <tr>
                    <td style="width: 500px; background: #003366; -webkit-border-radius: 10px; -moz-border-radius: 10px; -ms-border-radius: 10px; -o-border-radius: 10px; border-radius: 10px;">
                    <img src="http://www.caronchiro.com/feedback/png/logo.png" alt="Logo" style="width: 200px;">
                    </td>                                                               
                </tr>
                <tr>
                    <td>
                        <br>
                    </td>                                                       
                </tr>   
                <tr>
                    <td style="height: 20px;">
                    </td>
                </tr>
                <tr>
                    <td>
                        <br>
                    </td>                                                       
                </tr>   
                <tr>
                    <td>
                        <h3>A friendly hello from Caron Chiropractic!</h3>
                    </td>
                </tr>
                <tr>
                    <td>
                        <br>
                    </td>                                                       
                </tr>   
                <tr>
                    <td>
                        <p>We would like to hear about your experience with us. If you have a moment, please take our two-question survey.</p>
                    </td>
                </tr>
                <tr>
                    <td>
                        <br>
                    </td>                                                       
                </tr>                                                       
                <tr>
                    <td>
                        <a href="http://www.caronchiro.com/feedback/survey.php" style="background: #003366; border: none; padding: 5px 10px 5px 10px; text-shadow: 1px 1px #000; color: #FFF; text-decoration: none; -webkit-border-radius: 10px; -moz-border-radius: 10px; -ms-border-radius: 10px; -o-border-radius: 10px; border-radius: 10px;">Take the survey!</a><br><br>
                    </td>
                </tr>
                <tr>
                    <td>
                        <p>Thank you for helping us improve our services.</p>
                    </td>
                </tr>
                <tr>
                    <td>
                        <a href="http://www.caronchiro.com/feedback/unsubscribe.php?id='.md5($to).'" style="text-decoration: none; color: #003366;">Unsubscribe</a>
                    </td>
                </tr>
                <tr>
                    <td>
                        <br>
                    </td>                                                       
                </tr>
                <tr>
                    <td>
                        <p style="color: #B7B7B7;">CopyRight &copy; 2014</p>
                    </td>
                </tr>
            </table>';

            $subject = "A friendly hello from Caron Chiropractic!"; 
            mail($to,$subject,$message,$headers);                                                                       
            }
        }           
    }
}
Emi
  • 1,165
  • 4
  • 15
  • 26
  • 3
    Most of the time it is not in the code you make. The problem lies in the email adress of the smtp server. This is atleast something I found out since I had the same problem. this is also the reason you often see a message like "An email has been send to ... also check your spam folder" – SuperDJ Aug 28 '14 at 11:48
  • +1 for a nice explanation. It's not your code, it has to with your email's content and your host company's smtp server. – Basit Aug 28 '14 at 11:51
  • So, in this case, what should be the solution? – Emi Aug 28 '14 at 11:59

0 Answers0