我正在使用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应用程序工作流将此设置为默认邮件传输。这在localhost中工作正常,但在生产中失败。发送过程如下:
$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}
正如我所说,我可以使用相同的传输配置从localhost发送电子邮件,甚至我有一个Gmail帐户检查具有相同配置的新电子邮件(至少是相同的身份验证凭据)并且它正在运行。 / p>
我已经测试了创建一个不同的电子邮件帐户以用作我的SMTP传输。而不是“no-reply@mydomain.com”,我称之为“noreply@mydomain.com”,密码完全不同。同样,它从localhost可以正常工作,但在生产中失败。
但我已经使用现有帐户(“admin@mydomain.com”帐户凭据)对其进行了测试,并且它在生产和本地主机中都有效!!
为什么会发生这种情况?
答案 0 :(得分:0)
从查看ZF代码,邮件服务器本身返回消息Incorrect authentication data
,而不是Zend Framework特有的消息。消息本身可能以535
错误代码的形式返回。
如果有可能,请查看您是否可以使用tcpdump
,Wireshark或您首选的网络分析仪从生产系统中获取数据包。
既然你说它在生产和开发方面都有不同的帐号,我认为auth失败是因为你没有使用SSL / TLS,或者mail.mydomain.com
解析为不同的IP地址在两个系统上。
此时我有兴趣看到邮件事务的数据包捕获,因为这可能是查看2个系统上登录过程之间差异的唯一方法。
希望有所帮助。