Details
Description
Bug Description
SMTP servers may respond to commands with multi-line responses. A response is not complete until a response message NOT prefixed by '-' is found. However, Zend_Mail_Protocol_Abstract throws an exception before reading the entire response, leading to a truncated error message being included in the exception and the object being left in an unusable state (when it could/should be left usable).
Example multi-line SMTP response to an SMTP RCPT command
550-5.1.1 The email account that you tried to reach does not exist. Please try 550-5.1.1 double-checking the recipient's email address for typos or 550-5.1.1 unnecessary spaces. Learn more at 550 5.1.1 http://mail.google.com/support/bin/answer.py?answer=6596 xxxxxxxxxx.xx
The _expect() method of Zend_Mail_Protocol_Abstract throws an exception upon encountering the first "550" line rather than reading the entire multi-line response before throwing the exception. This causes two problems:
(1) The exception thrown does not contain the full response from the SMTP server, making troubleshooting and logging difficult, and
(2) If the exception is caught, the protocol adapter remains in an unusable state because there are (in this case) three response lines trapped in the receive buffer. Subsequent attempts to issue commands (an SMTP RSET command, for example) will fail because the next call to _expect() will receive the "550-5.1.1 double-checking the recipient..." line from the buffer which does not make sense.
Code to reproduce
$transport = new Zend_Mail_Transport_Smtp('ASPMX2.GOOGLEMAIL.com'); $mail = new Zend_Mail; $mail->setBodyText('foo') ->setFrom('foo@bar.com', 'foo') ->setSubject('foo') ->addTo('nobody@invalid-domain'); try { $transport->send($mail); } catch (Zend_Mail_Protocol_Exception $e) { echo $e->getMessage(); }
Expected Output
550-5.1.1 The email account that you tried to reach does not exist. Please try 550-5.1.1 double-checking the recipient's email address for typos or 550-5.1.1 unnecessary spaces. Learn more at 550 5.1.1 http://mail.google.com/support/bin/answer.py?answer=6596
Actual output
550-5.1.1 The email account that you tried to reach does not exist. Please try
Solution
See attached patch
Attachments
Issue Links
| This issue is dependecy of: | ||||
| ZF-8528 | Patch to add SMTP pipelining support and suppression of RCPT exceptions to Zend_Mail_Protocol_Smtp |
|
|
|
Patch for Zend/Mail/Protocol/Abstract.php