ZF-3641: Zend_Mail: Wrong MIME header encoding
(Posted for Tomas Markauskas on the fw-formats mailing list. The following text is copied from his mail.)
I noticed that subject headers in some emails sent with Zend_Mail aren't shown correctly in Gmail. I think the implementation of RFC 1522 in Zend_Mail::_encodeHeader() is not correct. The RFC 1522 says (http://tools.ietf.org/html/rfc1522#section-2), that if the string is too long to fit into 75 characters, it can be written as multiple encoded-words (and not encoded-texts), like this:
Subject: =?ISO-8859-1?B?SWYgeW91IGNhbiByZWFkIHRoaXMgeW8=?= =?ISO-8859-2?B?dSB1bmRlcnN0YW5kIHRoZSBleGFtcGxlLg==?=
(Thats from RFC 1522 Section 8: http://tools.ietf.org/html/rfc1522#section-8)
But Zend_Mail uses just the simple Quoted-Printable encoding, which is used in bodies etc. I still don't have any rigths to submit issues in Jira, so I created a page with a simple fix for Zend_Mail/Zend_Mime:
My two classes:
You can see the Zend_Mail result with an example string and the result of my fixed implementation on the page.
As you can also see, the current implementation has problems with strings, containing lots of spaces or question marks, ie. not every line is within required 75 characters. That's fixed there too now.