Zend Framework

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

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.9.6
  • Fix Version/s: 1.9.7
  • Component/s: Zend_Mail
  • Labels:
    None
  • Fix Version Priority:
    Must Have

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

Issue Links

Activity

Hide
Marc Hodgins added a comment -

Patch for Zend/Mail/Protocol/Abstract.php

Show
Marc Hodgins added a comment - Patch for Zend/Mail/Protocol/Abstract.php
Hide
Satoru Yoshida added a comment -

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

Show
Satoru Yoshida added a comment - Thank You for report , Marc. I solved this at SVN trunk r19629
Hide
Satoru Yoshida added a comment -

Change to next mini. SVN r19916 in 1.9 branch.

Show
Satoru Yoshida added a comment - Change to next mini. SVN r19916 in 1.9 branch.

People

Vote (1)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: