Issues

ZF-8511: Zend_Mail_Protocol_Abstract - truncates server response when SMTP server responds with umultiple line error message

Issue Type: Bug Created: 2009-12-09T23:57:05.000+0000 Last Updated: 2010-11-24T09:52:35.000+0000 Status: Resolved Fix version(s): - 1.9.7 (11/Jan/10)

Reporter: Marc Hodgins (mjh_ca) Assignee: Satoru Yoshida (satoruyoshida) Tags: - Zend_Mail

Related issues: - ZF-8528

Attachments: - Zend_Mail_Protocol_Abstract.patch

Description

h2. 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).

h2. Example multi-line SMTP response to an SMTP RCPT command

<pre class="literal">
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 <a href="http://mail.google.com/support/bin/answer.py?answer=6596">http://mail.google.com/support/bin/…</a> 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.

h2. Code to reproduce

<pre class="highlight">
$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();
}

h2. Expected Output

<pre class="literal">
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 <a href="http://mail.google.com/support/bin/answer.py?answer=6596">http://mail.google.com/support/bin/…</a>

h2. Actual output

<pre class="literal">
550-5.1.1 The email account that you tried to reach does not exist. Please try

h2. Solution

See attached patch

Comments

Posted by Marc Hodgins (mjh_ca) on 2009-12-10T00:00:18.000+0000

Patch for Zend/Mail/Protocol/Abstract.php

Posted by Satoru Yoshida (satoruyoshida) on 2009-12-14T02:14:03.000+0000

Thank You for report , Marc. I solved this at SVN trunk r19629

Posted by Satoru Yoshida (satoruyoshida) on 2009-12-24T02:37:04.000+0000

Change to next mini. SVN r19916 in 1.9 branch.

Have you found an issue?

See the Overview section for more details.

Copyright

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

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

Contacts