473,406 Members | 2,713 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Trouble with email package

Hallöchen!

I thought that with the following code snippet, I could generate a
MIME email stub:

#!/usr/bin/env python
# -*- coding: utf-8 -*-
from email.MIMEText import MIMEText
from email.Generator import Generator
import sys

message = MIMEText(u"Hallöchen!", _charset="utf-8")
Generator(sys.stdout).flatten(message)

However, MIMEText doesn't see that u"Hallöchen!" is a unicode and
encodes it accoring to _charset. Additionally, it is encoded as
base64 (why?). But okay, I added some lines to work around it:

#!/usr/bin/env python
# -*- coding: utf-8 -*-
from email.MIMEText import MIMEText
from email.Generator import Generator
from email.Charset import Charset
import sys

charset = Charset("utf-8")
charset.body_encoding = None
message = MIMEText(u"Hallöchen!".encode("utf-8"), _charset="utf-8")
message.set_charset(charset)
Generator(sys.stdout).flatten(message)

However, the result of this is

Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64

Hallöchen!

The Content-Transfer-Encoding is wrong. Okay (well, not okay but)
then I added message["Content-Transfer-Encoding"] = "8bit" to my
code and got

Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Transfer-Encoding: 8bit

Hallöchen!

I mean, I can work around anything, but is the email package just
rather buggy or do I something completely misguided here? Thanks
for any hints!

Tschö,
Torsten.

--
Torsten Bronger, aquisgrana, europa vetus
Jabber ID: br*****@jabber.org
(See http://ime.webhop.org for ICQ, MSN, etc.)
Jul 16 '07 #1
2 1450
Hallöchen!

Ingrid Bronger writes:
[...]

The Content-Transfer-Encoding is wrong. Okay (well, not okay but)
then I added message["Content-Transfer-Encoding"] = "8bit" to my
code and got

Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Transfer-Encoding: 8bit

Hallöchen!
I found the cause of this part of my trouble.

Tschö,
Torsten.

--
Torsten Bronger, aquisgrana, europa vetus
Jabber ID: br*****@jabber.org
(See http://ime.webhop.org for ICQ, MSN, etc.)
Jul 16 '07 #2
Hi there,
What was the solution you found?
Could you please post it? I'm having the same problem... ;o(
Thanks!
Harel

On Jul 16, 2:53 pm, Torsten Bronger <bron...@physik.rwth-aachen.de>
wrote:
Hallöchen!

Ingrid Bronger writes:
[...]
The Content-Transfer-Encoding is wrong. Okay (well, not okay but)
then I added message["Content-Transfer-Encoding"] = "8bit" to my
code and got
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Transfer-Encoding: 8bit
Hallöchen!

I found the cause of this part of my trouble.

Tschö,
Torsten.

--
Torsten Bronger, aquisgrana, europa vetus
Jabber ID: bron...@jabber.org
(Seehttp://ime.webhop.orgfor ICQ, MSN, etc.)

Jul 24 '07 #3

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

Similar topics

3
by: Roger Godefroy | last post by:
Hi there, Anybody an idea which phpscript I could use for a helpdesk. E-Mail messages sent to support@blabla.com should automaticaly being transfered to the system and email the user back with a...
4
by: Lol McBride | last post by:
Hi all, I'm developing an OOP program and trying to be smart by using unittest to help me to catch as many bugs as possible during development.Unfortunately I've hit a snag which I believe is to...
3
by: Phillip | last post by:
Some people tipped me off on some possibilities to tackle my https problem. Those have definitely gotten me further in cornering the problem. Thank you. But: No matter what I do to open a...
3
by: Charles Krug | last post by:
List: I'm trying to use the example files from Programming Python, 2nd Ed. I've copied them into c:\Python24\Examples\PP2E. Launching any of the examples programs by themselves seems to work...
5
by: lkrubner | last post by:
Go to this page: http://www.publicpen.com/designer/mcControlPanel.php?arrangement=createweblogsForm.php You'll need to login, use these: username: designer password: designer123 This is...
1
by: David | last post by:
Hi, I have a form with a sub-form. The Main form shows a selected product, and the sub-form shows the package contents for that product as follows: Item | Qty | Print (Checkbox) ...
4
by: Jim Bancroft | last post by:
Hi everyone, I've recently ported a COM component into .Net using a runtime callable wrapper. The component in question is SQL Server's DTS package, if that helps. The import worked well...
1
by: drife | last post by:
Hello, I use the Python Numeric package extensively, and had been an avid user of the "old" scipy. In my view, both pieces of software are truly first rate, and have greatly improved my...
9
Steel546
by: Steel546 | last post by:
This program is used to calculate GPA. I'm having trouble actually getting an output. Alright, I KNOW that I don't have an output statement, but I don't know where to put it... heh. Netbeans keeps...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.