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


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


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

As workaround you can do one of the following options:



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

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?

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