Issues

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

Description

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('example@example.org', 'My Name'); echo $mail->toString();

Result:

From: =?UTF-8?Q?My=20Name?= example@example.org

Expected result:

From: My Name example@example.org

Comments

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->headers()->get('From')->setEncoding('ASCII');

$mail->headers()->setEncoding('ASCII');

$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: https://github.com/zendframework/zf2/issues/2492