469,890 Members | 2,154 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,890 developers. It's quick & easy.

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

Hi all. 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'] = 't***@o2.pl'
Message['To'] = 'g*@o2.pl'
SMTPServer=smtplib.SMTP(ConfigurationManager.SMTPS erver)
SMTPServer.sendmail('t***@o2.pl','g*@o2.pl', Message.as_string())

Message looks like this:
Subject: Nowe has³o
\n
\n
Nowe email z haslem......

I looked how smtp serwer see my message and I notice that it looks like
content of the message is convert by BASE64 but not the subject. What
I'm doing wrong? can anyone tell me?
Apr 14 '06 #1
1 2240
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'] = 't***@o2.pl'
Message['To'] = 'g*@o2.pl'
SMTPServer=smtplib.SMTP(ConfigurationManager.SMTPS erver)
SMTPServer.sendmail('t***@o2.pl','g*@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
Apr 14 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by kingski | last post: by
4 posts views Thread by Roger Withnell | last post: by
20 posts views Thread by Chris Withers | last post: by
2 posts views Thread by Torsten Bronger | last post: by
3 posts views Thread by CJM | last post: by
2 posts views Thread by optimistx | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.