ZF-11977: Zend_Mail::addHeader() UNfolds long headers, then throws exception

Issue Type: Bug Created: 2012-01-06T16:10:49.000+0000 Last Updated: 2012-01-06T16:10:49.000+0000 Status: Open Fix version(s): Reporter: Linus R (silverquick) Assignee: Dolf Schimmel (Freeaqingme) (freak) Tags: - Zend_Mail

Related issues: Attachments:


If you pass a properly folded mail header to Zend_Mail::addHeader(), it strips all CRLF when it calls _filterOther(). It *sometimes* encodes the header value (as either QP or Base64), but only if it contains non-printable characters. So there's a case where you have a long, but properly-folded header, with no special characters, but when you add it to your Zend_Mail and send, it throws an exception, because after stripping all the CRLF, the header (now a single line) is > 998 chars.

Code to reproduce:

addHeader('X-Folded-Header-Test', $foldedHeader); $mail->setFrom('') ->addTo('') ->setSubject('Folded header test') ->setBodyText('This will throw a long header exception'); $mail->send(); ?> For me, this became an issue because I'm using SendGrid's SMTP API, which accepts a special header containing parameters in JSON format, which can get quite long and needs to be folded -- but then Zend\_Mail UNfolds it.

There are a number of temporary workarounds possible by subclassing Zend_Mail, but it seems that if it really needs to strip the CRLF (I assume there's a good reason), then _encodeHeader() should look at the header length, and *always* encode long values, even if they don't contain non-printable characters. At least, this was the response I got from my question here:…


No comments to display

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.