* Ben Finney <[email protected]>, 2016-03-09, 10:51:
On 06-Mar-2016, efkin wrote:
This should fix email headers that were not properly rendered.
Thank you, efkin, for making a patch.
I think that is addressing the problem in the wrong place.
The template tag should not do any encoding. Instead, it should just do
template interpolation, and return the Unicode text.
Encoding that text for transmission should be done only after the whole
message is composed.
So I think the correct solution entails:
* In ‘backend.templatetags.nm.formataddr’, remove the ‘encode’ call.
* In ‘backend.email.send_notification’, encode all fields of the header
(using ‘email.header.Header’ as you suggest).
No, that wouldn't work:
email.utils.formataddr((u'Cédric Boutillier', '[email protected]'))
u'C\xe9dric Boutillier <[email protected]>'
str(email.header.Header(_))
'=?utf-8?q?C=C3=A9dric_Boutillier_=3Cboutil=40debian=2Eorg=3E?='
The result is not a valid address.
RFC 2047 encoding must be applied only to the display-name part (as it
was done in the original patch), not the whole address.
--
Jakub Wilk