我正在使用 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 传输。而不是“no-reply@mydomain.com”,我称之为“noreply@mydomain.com”,密码完全不同。同样,它在本地主机上工作正常,但在生产中失败。
但是我已经用一个已经存在的帐户(“admin@mydomain.com”帐户凭据)对其进行了测试,它在生产和本地主机中都有效!!
为什么会发生这种情况?