ZF-10249: Missing inclusion of SMTP status code in Zend_Mail_Protocol_Exception

Issue Type: Bug Created: 2010-07-30T04:48:35.000+0000 Last Updated: 2010-11-24T10:09:20.000+0000 Status: Resolved Fix version(s): Reporter: Eutychus (eutychus) Assignee: Marc Hodgins (mjh_ca) Tags: - Zend_Mail

Related issues: - ZF-10741



I asked this month before but never received a satisfying answers:

If I Use a Zend_Mail_Transport_Smtp for mail transport. How could I receive the Status code returned by the server on any errors.

Example: 451 greylisted - try again later

The Zend_Mail_Protocol_Exception only contains the "greylisted - try again later" which may vary between servers. The getCode() Method only returns 0.

To me this is a bug of the Zend_Mail_Transport_Smtp and I can't believe that noone else had this problem before.


Posted by Eutychus (eutychus) on 2010-07-30T05:43:41.000+0000

Maybe it could be possible to modify Zend_Mail_Protocol_Abstract::_expect() to submit servers response code via Exception code (which should solve my problem):

{color:red} $errCode = 0;{color} do { $this->_response[] = $result = $this->_receive($timeout); list($cmd, $more, $msg) = preg_split('/([\s-]+)/', $result, 2, PREG_SPLIT_DELIM_CAPTURE);

        if ($errMsg !== '') {
            $errMsg .= ' ' . $msg;
        } elseif ($cmd === null || !in_array($cmd, $code)) {
            {color:red} $errCode = $cmd;{color}
            $errMsg =  $msg;

} while (strpos($more, '-') === 0);

if ($errMsg !== '') { /** * @see Zend_Mail_Protocol_Exception */ require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception($errMsg{color:red}, $errCode{color}); }

Posted by Marc Hodgins (mjh_ca) on 2010-11-24T10:09:08.000+0000

Thanks for the bug report. Addressed this in the patch attached to ZF-10741 as it was necessary to have access to the SMTP status codes for the unit tests on ZF-10741.

Posted by Marc Hodgins (mjh_ca) on 2010-11-24T10:09:20.000+0000

Closing this ticket as duplicate for now and linking to ZF-10741 for resolution.

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.