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

Grzegorz Ślusarek against at spam.pl
Fri Apr 14 05:45:35 EDT 2006


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'] = '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())

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?



More information about the Python-list mailing list