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('<e...@example.com>')
>>> h.encode()
'=?iso-8859-1?q?=C9ric?= <e...@example.com>'
>>> m = Message()
>>> m['Sender'] = h
>>> print(m)
Sender: =?iso-8859-1?q?=C9ric?= <e...@example.com>

In 3.3 this will work:

>>> m = Message()
>>> m['Sender'] = formataddr(('Éric', 'e...@example.com'))
>>> print(m)
Sender: =?iso-8859-1?q?=C9ric?= <e...@example.com>

But even better, so will this:

>>> m = Message(policy=policy.SMTP)
>>> m['From'] = "Günter Weiße <jarau...@igpm.rwth-aachen.de>"
>>> print(m)
From: =?utf-8?q?G=C3=BCnter_Wei=C3=9Fe?= <jarau...@igpm.rwth-aachen.de>

----------
resolution:  -> works for me
stage:  -> committed/rejected
status: open -> closed

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue15763>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to