History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: ZF-326
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Simon Mundy
Reporter: Matthew Leverton
Votes: 3
Watchers: 5
Operations

If you were logged in you would be able to see more operations.
Google issue summary
Zend Framework

SMTP transport is not prepending dots to lines beginning with a dot

Created: 18/Aug/06 11:00 AM   Updated: 18/Jan/08 09:31 PM
Component/s: Zend_Mail
Affects Version/s: 0.1.5
Fix Version/s: None

Time Tracking:
Not Specified

File Attachments: 1. File smtp-dot.diff (0.7 kb)
2. File UPDATED-smtp-dot.diff (0.7 kb)

Issue Links:
Duplicate
 

Resolution Date: 18/Jan/08 09:31 PM


 Description  « Hide
Zend/Mail/Transport/Smtp.php does not insert a leading dot for every line that begins with a dot. I've quoted the RFC below.

See Section 4.5.2 of RFC 2821

  • Before sending a line of mail text, the SMTP client checks the
    first character of the line. If it is a period, one additional
    period is inserted at the beginning of the line.
  • When a line of mail text is received by the SMTP server, it checks
    the line. If the line is composed of a single period, it is
    treated as the end of mail indicator. If the first character is a
    period and there are other characters on the line, the first
    character is deleted.


 All   Comments   Work Log   Change History   FishEye   Crucible      Sort Order: Ascending order - Click to sort in descending order
Matthew Leverton - 18/Aug/06 11:00 AM
A patch to conform to the RFC.

Simon Mundy - 20/Sep/06 06:28 PM
I've updated the priority to Major, as this still has the potential to mangle emails (e.g. broken images) in rare situations.

Further to this, I discovered that Matthew Leverton's patch still wasn't catching a few examples of lines where the leading character was a '.'. I traced it back to the fact that Zend_Mail_Transport_Abstract defines a line end as '/r/n' whereas Zend_Mime was using '/n' as a line end.

Substituting $this->EOL with Zend_Mime::LINEEND did the trick - here's the diff (and will attach separately):-

===================================================================
— library/Zend/Mail/Transport/Smtp.php (revision 1084)
+++ library/Zend/Mail/Transport/Smtp.php (working copy)
@@ -187,10 +187,10 @@
{
$this->_send('DATA');
$this->_expect(354);

  • foreach(explode($this->EOL, $data) as $line) {
  • if ($line=='.') {
    + foreach(explode(Zend_Mime::LINEEND, $data) as $line)
    Unknown macro: {+ if (strpos($line, '.') === 0) { // important. replace single dot on a line - $line='..'; + $line = '.' . $line; } $this->_send($line); }

Simon Mundy - 20/Sep/06 06:28 PM
Fixes erroneous detection of line endings

Bill Karwin - 28/Nov/06 05:51 PM
Scheduling for 0.7.0 release.

Aren Sandersen - 11/Jul/07 04:40 PM
This issue has regressed. Simon's comments on 20 Sep still apply – the "foreach(explode($this->EOL, $data) as $line) { " (now in Mail/Protocol/Smtp.php) is using self::EOL instead of Zend_Mime::LINEEND.

Darby Felton - 12/Jul/07 06:48 AM
Reopening on behalf of Aren Sandersen.

Simon Mundy - 14/Jul/07 04:06 PM
I'm not quite sure why this was re-opened - the updated patch applies to Zend_Mail_Transport_Smtp, but for a long time now the handling of pre-prending the dot is carried out by Zend_Mail_Protocol_Smtp, and the code in data() definitely handles the 'dot' correctly.

Aren Sandersen - 15/Jul/07 08:14 PM
Zend_Mime's encodeQuotedPrintable() uses LINEND ("\n") as the line-break sequence, but Zend_Mail_Protocol_Smtp's data() method is looking for self::EOL ("\r\n") as line-breaks. Since these don't match, newlines inserted as a result of quoted-printable encoding aren't detected properly and this issue happens.

Please re-open.


Simon Mundy - 17/Jul/07 05:50 AM
Further investigation of the issue by Aren Sandersen pointed to a logic error in Smtp components

Simon Mundy - 17/Jul/07 05:52 AM
Resolution committed in SVN revision 5724 - please test and confirm the issue is fixed.

Aren Sandersen - 17/Jul/07 03:26 PM
Confirmed; my tests show the issue is fixed.

Todd Rhodes - 19/Jul/07 03:09 PM
This also fixed my missing dot issue, but seemed to introduce a new issue. When I use setBodyHtml() and setBodyText() together to create the email, the resulting sent email only shows the text version with:

'Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable'

displayed at the top of the received email text. The text version of the email is shown, not the html as would be expected. In addition, long email text is mangled and interspersed with various line break characters.


Darby Felton - 30/Jul/07 09:29 AM
Fix version after 1.0.1.

Simon Mundy - 05/Nov/07 07:50 PM
Todd, can you please verify this behaviour occurs in release 1.0.2? If so, can you please attach new files to this issue with your code, the original message you are trying to send and - if possible - a dump of the resulting Zend_Mail object just before it is sent.

Simon Mundy - 18/Jan/08 09:31 PM
No further evidence of bug exists