R. David Murray added the comment:
Doing non-ASCII email in python before 3.3 is a bit of a pain and not as well
documented as it should be. 3.3 will work more like you expect, if you use the
new provisional policies (which are intended to become standard in 3.4, after a
the bake-in period in 3.3).
For 3.2, you need to handle encoding addresses using utils.formataddr and
header.Header:
>>> h = Header(header_name='Sender')
>>> h.append("Éric", 'latin-1')
>>> h.append('<[email protected]>')
>>> h.encode()
'=?iso-8859-1?q?=C9ric?= <[email protected]>'
>>> m = Message()
>>> m['Sender'] = h
>>> print(m)
Sender: =?iso-8859-1?q?=C9ric?= <[email protected]>
In 3.3 this will work:
>>> m = Message()
>>> m['Sender'] = formataddr(('Éric', '[email protected]'))
>>> print(m)
Sender: =?iso-8859-1?q?=C9ric?= <[email protected]>
But even better, so will this:
>>> m = Message(policy=policy.SMTP)
>>> m['From'] = "Günter Weiße <[email protected]>"
>>> print(m)
From: =?utf-8?q?G=C3=BCnter_Wei=C3=9Fe?= <[email protected]>
----------
resolution: -> works for me
stage: -> committed/rejected
status: open -> closed
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue15763>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com