473,242 Members | 2,405 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,242 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 1443
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: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.