ZF2-364: Zend\Mail\Header::mimeEncodeValue unnecessarily encodes pure-ASCII headers

Issue Type: Bug Created: 2012-06-17T10:55:17.000+0000 Last Updated: 2012-10-08T20:15:12.000+0000 Status: Closed Fix version(s): Reporter: Steffen Weber (steffen) Assignee: Maks 3w (maks3w) Tags: - Zend\Mail

Related issues: Attachments:


In contrast to ZF1, ZF2 unnecessarily encodes headers even if they contain only ASCII characters. Demo:

$mail = new Zend\Mail\Message(); $mail->setEncoding('UTF-8'); $mail->setFrom('', 'My Name'); echo $mail->toString();


From: =?UTF-8?Q?My=20Name?=

Expected result:

From: My Name


Posted by Steffen Weber (steffen) on 2012-06-17T12:19:14.000+0000

I think the method Zend\Mime\Mime::isPrintable can be used to determine if a header has to be encoded.

Posted by Maks 3w (maks3w) on 2012-06-18T14:38:08.000+0000

As workaround you can do one of the following options:

<pre class="highlight">


$mail->getHeader('From', null)->setEncoding('ASCII');

Posted by Steffen Weber (steffen) on 2012-07-07T10:48:28.000+0000

I've just downloaded ZF2 Beta 5. Even the "Date" header is encoded. Maybe some classes like Zend\Mail\Header\Date should just ignore calls of their "setEncoding" method?

Posted by Ralph Schindler (ralph) on 2012-10-08T20:15:12.000+0000

This issue has been closed on Jira and moved to GitHub for issue tracking. To continue following the resolution of this issues, please visit:

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.