Mail()函数php将邮件发送到垃圾邮件过滤器

时间:2014-08-28 11:46:20

标签: php html email spam

我正在尝试将我的简报从php文件发送到数据库中的某些联系人。但是,当我将邮件发送到Google Mail帐户时,邮件将转到垃圾邮件过滤器而非收件箱中。如果我将邮件发送到Yahoo Mail帐户,它的工作正常。

我尝试了很多可能性,而且我编写的代码必须是一封很好的电子邮件,但没有G-Mail的结果。如果你能给我一个想法,让我的PHP功能不那么垃圾,我将不胜感激。提前谢谢。

这个的PHP代码是:

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);                                                                       
            }
        }           
    }
}

0 个答案:

没有答案