【问题标题】:phpMailer Failing AuthenticationphpMailer 认证失败
【发布时间】:2014-07-19 11:32:06
【问题描述】:

我刚刚设置了一个自动发送邮件给用户的电子邮件。

NSlookup

这是域的 NSLookup 详细信息:

sballiance.co.uk name server ns2.mainnameserver.com.
sballiance.co.uk mail is handled by 0 sballiance-co-uk.mail.protection.outlook.com.
sballiance.co.uk descriptive text "v=spf1 include:spf.protection.outlook.com -all"
sballiance.co.uk has address 176.32.230.12
sballiance.co.uk descriptive text "MS=ms71078976"
sballiance.co.uk has SOA record ns.mainnameserver.com. hostmaster.mainnameserver.com. 2014032747 86400 604800 2419200 10800
sballiance.co.uk name server ns.mainnameserver.com.

phpMailer 设置

以下是我的 phpMailer 设置的重要细节:

public $Host          = 'sballiance-co-uk.mail.protection.outlook.com';
public $Port          = 465; //I've kept this to default(?)
public $SMTPSecure    = '';
public $SMTPAuth      = true; //Default is false
public $Username      = 'no-reply@sballiance.co.uk';
public $Password      = '%password%'; //this username/password combination has been set up for that email address in my cPanel equivalent (and works when checking webmail)

这是发送邮件的实际功能:

function sendMail($email,$username,$subject,$content){
    include "mail/class.phpmailer.php";
    include "mail/class.pop3.php";
    include "mail/class.smtp.php";

    $mail             = new PHPMailer();
    $body             = $content;

    $mail->SetFrom('no-reply@sballiance.co.uk', 'SB Alliance');

    $mail->AddReplyTo('no-reply@sballiance.co.uk', 'SB Alliance');

    $address = $email;
    $mail->AddAddress($address, $username);

    $mail->Subject    = $subject;

    $mail->AltBody    = 'This email requires a compatible HTML email reader';

    $mail->MsgHTML($body);

    if(!$mail->Send()) {
        return "Mailer Error: " . $mail->ErrorInfo;
    } else {
        return "sent";
    }
}

我还尝试将$Host 更改为其他似乎相关的,例如mail.sballiance.co.uk(用于网络邮件服务)和outlook.office365.com,但无济于事。

客户端报告

出现的错误如下所示:

Be careful! This sender has failed our fraud detection checks.

和这样的标题:

x-store-info:sbevkl2QZR7OXo7WID5ZcdV2tiiWGqTnv73VPHTe3HZillThz1CwMFmvE6RyGLdUgeYElVvsR9ZinU/JS1XJwJa/Khp9v2l3PYv0uCTAYlo0Nw1MBZNhWNveRqIhDM6d34x4hW3u5wA=
Authentication-Results: hotmail.com; spf=fail (sender IP is 79.170.43.23) smtp.mailfrom=no-reply@sballiance.co.uk; dkim=none header.d=sballiance.co.uk; x-hmca=fail header.id=no-reply@sballiance.co.uk
X-SID-PRA: no-reply@sballiance.co.uk
X-AUTH-Result: FAIL
X-SID-Result: FAIL
X-Message-Status: n:n
X-Message-Delivery: Vj0xLjE7dXM9MDtsPTA7YT0xO0Q9MTtHRD0xO1NDTD0w
X-Message-Info: NhFq/7gR1vR7v/qBzEYftopex6RvS/TlaqofkDjfprtVulohbgulVNuxNJEURduxeriG1vH3EjyGlkDh8pik4NJPpySLFvCsUWX/ZpVUFHceF+K8uNNco1TVASfjWcYNog2EKJ3v8ua8pnX3qRJRxa1wxY3PGztq0u1pYpCfb8zHPYLkdXhR07X/MA1HZDyMtY3rLSQs6CMI3Oo7ANz2/tJ+D0LMcw+i
Received: from mailscan1.extendcp.co.uk ([79.170.43.23]) by SNT004-MC1F56.hotmail.com over TLS secured channel with Microsoft SMTPSVC(7.5.7601.22678);
    Thu, 29 May 2014 12:42:44 -0700
Received: from lb1.hi.local ([10.0.1.197] helo=mailscan0.hi.local)
    by mailscan-g65.hi.local with esmtp (Exim 4.80.1)
    (envelope-from <no-reply@sballiance.co.uk>)
    id 1Wq6Dq-0000qO-Rj
    for %myemailaddress%; Thu, 29 May 2014 20:42:42 +0100
Received: from lb1.hi.local ([10.0.1.197] helo=web12.extendcp.co.uk)
    by mailscan0.hi.local with esmtps (UNKNOWN:DHE-RSA-AES256-GCM-SHA384:256)
    (Exim 4.80.1)
    (envelope-from <no-reply@sballiance.co.uk>)
    id 1Wq6Dp-000109-4y
    for %myemailaddress%; Thu, 29 May 2014 20:42:42 +0100
Received: from sballiance.co.uk by web12.extendcp.co.uk with local (Exim 4.80.1)
    (envelope-from <no-reply@sballiance.co.uk>)
    id 1Wq6Do-0005SG-Vb
    for %myemailaddress%; Thu, 29 May 2014 20:42:41 +0100

如何避免我的电子邮件未通过身份验证?

另外,如果需要任何其他信息,请告诉我,以便我对我的问题更有帮助。

【问题讨论】:

    标签: php email authentication sendmail phpmailer


    【解决方案1】:

    您有一个 SPF 记录,您发送的服务器未在其中列出,因此它未通过 SPF 检查:

    spf=fail (sender IP is 79.170.43.23)
    

    您可以通过将此子句添加到您的 SPF 记录来解决此问题:

    ip4:79.170.43.23
    

    或等效的a 子句。

    您的配置有点错误 - 事实上我很惊讶它完全按原样工作:

    public $SMTPSecure    = '';
    

    应该是:

    public $SMTPSecure    = 'ssl';
    

    除此之外,您的代码基于一个旧示例,并且包含了可能不需要的类。将您的代码基于up to date example 和latest PHPMailer。

    【讨论】:

      猜你喜欢
      • 2015-01-05
      • 1970-01-01
      • 2015-10-14
      • 2016-01-26
      • 2021-03-07
      • 2019-09-03
      • 2016-05-30
      • 2015-10-17
      • 2021-05-11
      相关资源
      最近更新 更多