sending email with charset utf-8 but subject is not coded properly

Rene Pijlman reply.in.the.newsgroup at my.address.is.invalid
Fri Apr 14 06:21:25 EDT 2006


Grzegorz ¦lusarek:
>I sending email using standard python modules smtplib, email, 
>coding email in utf but subject of message is not coded properly. In 
>subject i use my national characters (polish) and after send i get XX in 
>place these characters.
>Here is the code
>
>Message = email.message_from_string(pMessage)
>	Message.set_charset('utf-8')
>	Message['From'] = 'test at o2.pl'
>	Message['To'] = 'gt at o2.pl'
>	SMTPServer=smtplib.SMTP(ConfigurationManager.SMTPServer)
>	SMTPServer.sendmail('test at o2.pl','gt at o2.pl', Message.as_string())

I see no subject in this code.

"If you want to include non-ASCII characters in your email headers, say in
the Subject: or To: fields, you should use the Header class and assign the
field in the Message object to an instance of Header instead of using a
string for the header value."
http://docs.python.org/lib/module-email.Header.html

-- 
René Pijlman



More information about the Python-list mailing list