【问题标题】:PHP mail causing phishing warning on gmailPHP邮件在gmail上引起网络钓鱼警告
【发布时间】:2014-09-17 07:27:02
【问题描述】:

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

PHP 邮件程序代码:

<?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();

?>

【问题讨论】:

  • 这与PHPMailer无关。您正在使用 PHP 的 mail() 函数...

标签: php email


【解决方案1】:

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

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

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,并在谷歌上搜索其他大型处理程序(如雅虎)。

除此之外,请确保您添加了一个带有“一键式”OPT-OUT 删除选项的页脚,并说明此消息是代表发送的,以及原始发件人是谁。

干杯

【讨论】:

    【解决方案2】:

    您可以为您的网站设置 google 应用程序并获得一个 Username@yourwebsite.com gmail 帐户(更多信息:http://www.google.com/enterprise/apps/business/),或者您需要在当前服务器上设置一个电子邮件地址,即Username@yourwebsite.com 并将其用作 $mail-> 发件人地址。

    您的电子邮件收件人收到邮件是因为您告诉 google 从您的服务器发送一封电子邮件,然后您告诉他们邮件来自 gmail,但不是,它来自您的个人服务器。由于发件人地址和您的服务器地址不匹配,他们将其标记为垃圾邮件。这是 google 防止垃圾邮件的方式,对他们来说,如果你输入 $mail->from(YOURMOM@LOL.com) 就会一样。电子邮件仍会发送,但您的域名与@地址不匹配。

    【讨论】:

      【解决方案3】:

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

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

      【讨论】:

        猜你喜欢
        • 2023-04-10
        • 1970-01-01
        • 2015-02-16
        • 2011-09-25
        • 1970-01-01
        • 2012-08-27
        • 2014-12-27
        • 2012-10-14
        • 2019-10-26
        相关资源
        最近更新 更多