[issue4306] email package with unicode subject/body

Barry A. Warsaw report at bugs.python.org
Thu Nov 20 17:15:19 CET 2008


Barry A. Warsaw <barry at python.org> added the comment:

This example works though, and it also works in earlier Pythons.


from email.header import Header

def main():
    # coding: utf8
    ADDRESS = 'victor.stinner at haypocalc.com'
    from email.mime.text import MIMEText
    msg = MIMEText('accent \xe9\xf4\u0142', 'plain', 'utf-8')
    msg['Subject'] = Header('sujet \xe9\xf4\u0142'.encode('utf-8'),
                            'utf-8')
    msg['From'] = ADDRESS
    msg['To'] = ADDRESS
    text = msg.as_string()
    print("--- FLATTEN ---")
    print(text)
    return

main()

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


More information about the Python-bugs-list mailing list