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('email@example.com', 'file service'); $m->addTo('firstname.lastname@example.org', '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('172.30.62.221') );
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.