473,689 Members | 2,940 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Python's email module - problem with umlauts in some email clients

Hi there,

I wrote a short python script that sends an email using python's email
module and I am using Python 2.3.5.
The problem is, that umlauts are not displayed properly in some email
clients:

+ On a windows machine running thunderbird 1.0.2 umlauts are displayed
properly.
The email header contains "Content-type: text/plain; charset=utf-8"
so the email client's character encoding automatically switches to
"Unicode (UTF-8)"

+ On a solaris machine running thunderbird 1.5.0.8 and on a macintosh
machine running eudora umlauts are *not* displayed properly.
The email header does not contain any "Content-type". If I manually
switch the email client's character encoding to "Unicode (UTF-8)", the
umlauts are displayed properly. Therefore, I guess it has something to
do with the missing "Content-type: text/plain; charset=utf-8"
information in the email header.

Any idea why the "Content-type: text/plain; charset=utf-8" is missing?
Here is my script:

#------------------------------------------------------------------
# send email
from email.Header import Header
import email.Message
import email.Utils
import mimetypes
from smtplib import SMTP

host = 'mail.example.c om'
mFrom = 'a*********@exa mple.com'
mTo = 'f******@exampl e.com'
mSubj = u'f\xfcr'
mBody = u'f\xfcr foo bar'
mBody = mBody.encode('U TF-8')

mainMsg = email.Message.M essage()

mainMsg['From'] = mFrom
mainMsg['To'] = mTo
mainMsg['Subject'] = mSubj
mainMsg.set_pay load(mBody)

mainMsg['Date'] = email.Utils.for matdate(localti me=1)
mainMsg['Message-ID'] = email.Utils.mak e_msgid()
mainMsg['Mime-version'] = '1.0'
mainMsg['Content-type'] = 'text/plain; charset=utf-8'
mainMsg['Content-transfer-encoding'] = '8bit'
# 'quoted-printable' does not work either
# mainMsg['Content-Transfer-Encoding'] = 'quoted-printable'

s = SMTP(host)
s.sendmail(mFro m, [mTo], mainMsg.as_stri ng())
s.close()
#------------------------------------------------------------------

Regards,
Nico
Dec 8 '06 #1
0 1627

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

699
33914
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro capabilities, unfortunately. I'd like to know if it may be possible to add a powerful macro system to Python, while keeping its amazing syntax, and if it could be possible to add Pythonistic syntax to Lisp or Scheme, while keeping all of the...
0
8594
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8528
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8783
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8786
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7621
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5810
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4321
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4547
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
1952
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.