[issue12649] email.Header ignores maxlinelen when wrapping encoded words

R. David Murray report at bugs.python.org
Thu Jul 28 15:57:00 CEST 2011


R. David Murray <rdmurray at bitdance.com> added the comment:

You are using Header incorrectly.  It should look more like this:

    th = _e_header.Header(maxlinelen=200, header_name='To')
    th.append(tfc[:-1])
    th.append(wtc[:-1], charset='utf-8')
    th.append(tem)


This results in:

  To: ABCDEFGH =?utf-8?b?0ILYgeC5hOC8kuGPiuGauw==?= <abcdefg at hijk-lmnopqr.st>

Which is valid per RFC, which encoding the address is not.  A compliant mailer should be able to handle the Subject line from your version correctly, but not the To or From lines.

The fact that you don't want the trailing spaces is an artifact of the API.  Using this API requires more knowledge of the RFCs than anyone should want to have.  In Python 3.3 we will be introducing a new API in the email package that will make all of this *much* simpler.

The maxlinelen issue does appear to be a bug, though.

----------
keywords: +easy
nosy: +r.david.murray
title: email.Header corupts international email header and ignores maxlinelen in some cases -> email.Header ignores maxlinelen when wrapping encoded words
versions: +Python 3.2, Python 3.3

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12649>
_______________________________________


More information about the Python-bugs-list mailing list