phpMailer认证失败


phpMailer Failing Authentication

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

网路资讯查询

这是域的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 setup的重要细节:
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(用于webmail服务)和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

我怎么做才能避免我的电子邮件身份验证失败?

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

你有一个SPF记录,你发送的服务器不在其中,所以它没有通过SPF检查:

spf=fail (sender IP is 79.170.43.23)

您可以通过在SPF记录中添加以下子句来修复此问题:

ip4:79.170.43.23

或等价的a子句。

你的配置有一点错误——事实上我很惊讶它能正常工作:

public $SMTPSecure    = '';

应该是:

public $SMTPSecure    = 'ssl';

最重要的是,你的代码是基于一个旧的例子,你包含了一些可能不需要的类。基于最新的示例和最新的PHPMailer编写代码。