“Zend_Mail_Protocol_Exception:不正确的身份验证数据”发生在生产环境中,但不在本地主机中发生


"Zend_Mail_Protocol_Exception: Incorrect authentication data" happening in production, but NOT in localhost, using the same transport config

我正在使用Zend_Mail来交付基于Zend Frameowrk的MVC应用程序。传输配置如下:

; Mail (SMTP Transport)
resources.mail.transport.type       = smtp
resources.mail.transport.host       = "mail.mydomain.com"
resources.mail.transport.auth       = login
resources.mail.transport.username   = "no-reply@mydomain.com"
resources.mail.transport.password   = "mypasswordhere"
resources.mail.transport.register   = true
resources.mail.defaultFrom.email    = "no-reply@mydomain.com"
resources.mail.defaultFrom.name     = "Automatic email from mydomain.com"
resources.mail.defaultReplyTo.email = "no-reply@mydomain.com"
resources.mail.defaultReplyTo.name  = "Automatic email from mydomain.com"

Zend 应用程序工作流将其设置为默认邮件传输。这在本地主机中工作正常,但在生产中失败。发送过程如下:

$objMail = new Zend_Mail();
if( $fromEmail != null ){
    $objMail->setFrom($fromEmail, $fromName);
}
$objMail->addTo($to);
if( $cc != null ){
    $objMail->addCc($cc);
}
if( $bcc != null ){
    $objMail->addBcc($bcc);
}
$objMail->setSubject($subject);
if( $messageHtml != null ){
    $objMail->setBodyHtml($messageHtml, mb_detect_encoding($messageHtml));
}
if( $messageTxt != null ){
    $objMail->setBodyText($messageTxt, mb_detect_encoding($messageTxt));
}
$objMail->send();

生产中的例外情况是:

exception 'Zend_Mail_Protocol_Exception' with message 'Incorrect authentication data
' in /home/myuser/public_html/subdomains/myapp/library/Zend/Mail/Protocol/Abstract.php:431
Stack trace:
<<issue 0>> /home/myuser/public_html/subdomains/myapp/library/Zend/Mail/Protocol/Smtp/Auth/Login.php(95): Zend_Mail_Protocol_Abstract->_expect(235)
<<issue 1>> /home/myuser/public_html/subdomains/myapp/library/Zend/Mail/Protocol/Smtp.php(217): Zend_Mail_Protocol_Smtp_Auth_Login->auth()
<<issue 2>> /home/myuser/public_html/subdomains/myapp/library/Zend/Mail/Transport/Smtp.php(200): Zend_Mail_Protocol_Smtp->helo('localhost')
<<issue 3>> /home/myuser/public_html/subdomains/myapp/library/Zend/Mail/Transport/Abstract.php(348): Zend_Mail_Transport_Smtp->_sendMail()
<<issue 4>> /home/myuser/public_html/subdomains/myapp/library/Zend/Mail.php(1194): Zend_Mail_Transport_Abstract->send(Object(Zend_Mail))
<<issue 5>> /home/myuser/public_html/subdomains/myapp/application/controllers/MailController.php(404): Zend_Mail->send()
<<issue 6>> /home/myuser/public_html/subdomains/myapp/library/Zend/Controller/Action.php(516): MailController->sendmailAction()
<<issue 7>> /home/myuser/public_html/subdomains/myapp/library/Zend/Controller/Dispatcher/Standard.php(295): Zend_Controller_Action->dispatch('sendmailActi...')
<<issue 8>> /home/myuser/public_html/subdomains/myapp/library/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
<<issue 9>> /home/myuser/public_html/subdomains/myapp/library/Zend/Application/Bootstrap/Bootstrap.php(97): Zend_Controller_Front->dispatch()
<<issue 10>> /home/myuser/public_html/subdomains/myapp/library/Zend/Application.php(366): Zend_Application_Bootstrap_Bootstrap->run()
<<issue 11>> /home/myuser/public_html/subdomains/myapp/public/index.php(26): Zend_Application->run()
<<issue 12>> {main}

正如我所说,我可以使用相同的传输配置从本地主机发送电子邮件,甚至我有一个 Gmail 帐户检查具有相同配置(至少相同的身份验证凭据)的新电子邮件并且它正在工作。

我已经测试了创建一个不同的电子邮件帐户以用作我的 SMTP 传输。我称它为"noreply@mydomain.com",而不是"no-reply@mydomain.com",密码完全不同。同样,它在本地主机上工作正常,但在生产中失败。

但是我已经使用已经存在的帐户("admin@mydomain.com"帐户凭据)对其进行了测试,并且可以在生产和本地主机中工作!!

为什么会这样?

从查看 ZF 代码来看,邮件Incorrect authentication data是由邮件服务器本身返回的,而不是特定于 Zend Framework 的任何内容。 消息本身可能以535错误代码的形式返回。

如果有任何可能的方法,请查看是否可以使用tcpdump,Wireshark或您首选的网络分析仪从生产系统捕获数据包。

既然您说它在生产和开发中使用不同的帐户都可以正常工作,我认为身份验证不会失败,因为您没有使用 SSL/TLS,或者mail.mydomain.com解析为两个系统上的不同 IP 地址。

在这一点上,我有兴趣看到邮件事务的数据包捕获,因为这可能是查看两个系统上登录过程之间存在差异的唯一方法。

希望有帮助。