By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,758 Members | 1,264 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,758 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.