PHP邮件导致gmail上的网络钓鱼警告

时间:2014-09-17 07:27:03

标签: php email

我正在使用PHPMailer从我的网站发送自动电子邮件,在测试时,我注意到当我通过Gmail从网站发送邮件时,php邮件发送的电子邮件会在收件人端产生以下警告: 此消息可能尚未发送:example@gmail.com了解更多报告网络钓鱼。 但是当我使用其他电子邮件(如雅虎,Outlook)时,我的$contact_email中没有收到任何电子邮件。请帮我解决这个问题。

PHP Mailer代码:

<?php 
global $_REQUEST;
$response = array('error'=>'');

    $user_name = substr($_REQUEST['user_name'], 0, 20);
    $user_email = substr($_REQUEST['user_email'], 0, 40);
    $user_msg = $_REQUEST['user_msg'];

    $contact_email = 'contact.arefin@gmail.com';    

    if (trim($contact_email)!='') {
        $subj = 'Message from Official Website';
        $msg = "Name: $user_name
        E-mail: $user_email
        Message: $user_msg";

        $head = "Content-Type: text/plain; charset=\"utf-8\"\n"
            . "X-Mailer: PHP/" . phpversion() . "\n"
            . "Reply-To: $user_email\n"
            . "To: $contact_email\n"
            . "From: $user_email\n";

        if (!@mail($contact_email, $subj, $msg, $head)) {
            $response['error'] = 'Error send message!';
        }
    } else 
            $response['error'] = 'Error send message!';

    echo json_encode($response);
    die();

?>

3 个答案:

答案 0 :(得分:2)

当您发送批量电子邮件时,尤其是在模拟发件人地址时,您需要使用可能减少有多少服务器阻止您作为垃圾邮件发送者的最佳做法。

我认为你应该做的三件事是:

1)使用适当的邮件标题

将以下内容添加到您的代码中 - 通知这是批量发件人,以及OPT-OUT电子邮件地址:

.= "X-mailer: YOUR_SITE_DOMAIN Server" . "\r\n"; // this will identify the real sender
.= "Precedence: bulk" . "\r\n"; // this will say it is bulk sender
.= "List-Unsubscribe:info@YOUR_SITE_DOMAIN\r\n"; // this will reveal the OPT-OUT address

详细了解here

2)确保您的服务器域具有反向DNS记录。这将告诉收件人的服务器您的域确实在您的服务器上托管。

3)在您的域中发布SPF记录。您可以阅读有关它的更多信息here,并将其谷歌搜索给其他大型处理程序(如Yahoo)。

除此之外,请确保添加一个单击&#34;单击&#34; OPT-OUT删除选项和说明请注意,此邮件是代表发送的,谁是原始发件人。

干杯

答案 1 :(得分:1)

您可以为您的网站设置Google Apps并获取Username@yourwebsite.com gmail帐户(更多信息:http://www.google.com/enterprise/apps/business/),或者您需要在当前服务器上设置电子邮件地址这是Username@yourwebsite.com并将其用作$ mail-&gt;来自地址。

您的电子邮件收件人正在接收邮件,因为您要告诉Google从您的服务器发送电子邮件,然后您告诉他们该邮件来自gmail,而不是来自gmail,它来自你的个人服务器。由于发件人地址与您的服务器地址不匹配,因此将其标记为垃圾邮件。这是googles防止垃圾邮件的方式,如果你从(YOURMOM@LOL.com)输入$ mail-&gt;就可以了。电子邮件仍会发送,但您的域名与@地址不匹配。

答案 2 :(得分:0)

试试这段代码,在你的代码中我发现了一些我在这里解决的错误。

   global $_REQUEST;
    $response = array('error'=>'');

        $user_name = substr($_REQUEST['user_name'], 0, 20);
        $user_email = substr($_REQUEST['user_email'], 0, 40);
        $user_msg = $_REQUEST['user_msg'];

        $contact_email = 'contact.arefin@gmail.com'; 

        if (trim($contact_email)!='') {
            $subj = 'Message from Official Website';
            $msg = "Name: $user_name
            E-mail: $user_email
            Message: $user_msg";

            $head = "Content-Type: text/plain; charset=\"utf-8\"\n"
                . "X-Mailer: PHP/" . phpversion() . "\n"
                . "Reply-To: $user_email\n"
                . "To: $contact_email\n"
                . "From: $user_email\n";

            if (!@mail($contact_email, $subj, $msg, $head)) {
                $response['error'] = 'Error send message!';
            }else{
                 $response['error'] = 'success!';
            }
        } else {
        $response['error'] = 'Error send message!';
        }
        echo json_encode($response);    die();
相关问题