Email headers and non-ASCII characters

Christoph Haas email at christoph-haas.de
Thu Nov 23 15:20:44 CET 2006


On Thursday 23 November 2006 15:12, I wrote:
> My example code:
>
> =================================
> def sendmail(sender, recipient, body, subject):
>    message = MIMEText(body)
>    message['Subject'] = Header(subject, 'iso-8859-1')
>    message['From'] = Header(sender, 'iso-8859-1')
>    message['To'] = Header(recipient, 'iso-8859-1')
>
>    s = smtplib.SMTP()
>    s.connect()
>    s.sendmail(sender, recipient, message.as_string())
>    s.close()
> =================================

Just for completeness - of course I imported the Header methods from here:

from email.MIMEText import MIMEText
from email.Header import Header

 Christoph



More information about the Python-list mailing list