Internationalised email headers in Python

by Matt Sital-Singh on Jun 13, 2008
Filed Under:

Here is how you create international characters in email headers. Useful if people have umlauts and accents in their name:

>>> from email.message import Message
>>> from email.header import Header
>>> msg = Message()
>>> h = Header('p\xf6stal', 'iso-8859-1')
>>> msg['Subject'] = h
>>> print msg.as_string()
Subject: =?iso-8859-1?q?p=F6stal?=

More info here:

http://docs.python.org/lib/module-email.header.html

Filed under: , ,

Commenting has now closed on this post.

Follow us

— via Twitter

Is proudly sponsoring #BlueLightCamp today. If you want to come talk Open Source content management @HammerToe is there #blcamp
last month