ZF-4360: Incorrect LINELENGTH constant corrupts attachments


Since version 1.0.3 file attachments with Zend_Mail have been failing to decode correctly in my Zend Framework projects. I have come across ZF-4169 and ZF-1795 which led me to change the Zend_Mime::LINELENGTH to 72.

This fixes my corrupt attachments. In testing I see that the default of 74 is actually delivering encodings with line lengths of 77. This is over the RFC 2045 standard of 76:


Example Code: $m = new Zend_Mail(); $m->setBodyText('your file is attached'); $m->setFrom('downloads@asdf.com', 'file service'); $m->addTo('asdf@asdf.com', 'asdf'); $m->setSubject('dl test');

$file = '/home/me/cbd20080809.xls'; $attachBody = file_get_contents($file); $filename = basename($file); $m->createAttachment($attachBody, mime_content_type($file), Zend_Mime::DISPOSITION_ATTACHMENT, Zend_Mime::ENCODING_BASE64, $filename);

$m->send( new Zend_Mail_Transport_Smtp('') );

With this I will get consistently corrupt attachments unless I change Zend_Mime::LINELENGTH to 72. I have duplicated this behavior on 64bit boxes running RHEL4/5 and CentOS 5, php 5.2.5, and Zend Framework 1.0.3 - 1.6.

I hate modifying the framework code but I don't have an alternative.


76 also seems to work.

76 is the default value used by chunk_split().

I also tried 76 with success. I'm not an advocate of either, I just want Zend_Mail to send uncorrupted attachements out-of-the-box.

The weird thing is GMail manages to fix them somehow with 74, no other MTA does. They do some freaky things behind the scenes there.

Note to Zend:

Yet another release of the framework was released without this fix. I can't for the life of me figure out why such a trivial change wouldn't be merged into main. As it stands, I have to manually patch all my servers which is annoying.

Agreed, this is very trivial and easy to test. Is anyone out there listening?

Fixed with r12343. Changed to 72 to be compatible with other mailers.

Super exciting! Thanks Thomas!

Changing issues in preparation for the 1.7.0 release.