473,398 Members | 2,368 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,398 software developers and data experts.

Reading and writing Mozilla-mail in python

Hi all,

who can help on reading and writing mozilla-mail folders with python?
I wanted to implement something like an email-sync for mozilla-mail in
python. I did some tests, but something is strange with the email
(rfc822) modules in python. (The output of parsed messages is different
from the original input)

Any hints of how (what modules) this could be done in a portable manner?

Thanks,
Uwe

Jul 18 '05 #1
7 1647
On Tue, 09 Dec 2003 14:27:42 +0100, Uwe Grauer wrote:
Hi all,

who can help on reading and writing mozilla-mail folders with python?
What format are they? mbox?
I wanted to implement something like an email-sync for mozilla-mail in
python.
Some tools to do this already exist. Check on packages.debian.org. I
think one of them is called 'offlineimap' and is implemented in
python.
I did some tests, but something is strange with the email (rfc822)
modules in python. (The output of parsed messages is different from
the original input)


Use the 'email' module for handling individual email messages (not
rfc822). Note that both of those modules only process one message at
a time, not an entire mailbox.

-D

--
In the way of righteousness there is life;
along that path is immortality.
Proverbs 12:28

www: http://dman13.dyndns.org/~dman/ jabber: dm**@dman13.dyndns.org
Jul 18 '05 #2
After playing around with the mailbox an email modules i noticed some
strange behaviours:

after the first message is parsed, i got some (kind of parsing errors).

My code:

def test_copy(infile, outfile):
from mailbox import UnixMailbox
from email import message_from_file as mff
try:
fd = open(infile, 'r')
try:
for message in UnixMailbox(fd, mff):
print message
print '***********************************************'
finally:
fd.close()
except:
pass
return

output from script above:

.....
In-Reply-To: <3F************@web.de>
Sender: so*****@somewhere.de

Nein, leider noch nicht, komm auch erst in paar Tagen dazu.
Fro
***********************************************
From - Sun Dec 07 02:59:04 2003
X-UIDL: 6165
X-Mozilla-Status: 0001
X-Mozilla-Status2: 00000000
.....

Look at the Line: Fro

Whats going on here.

Could someone please verify this?

I'm using python 2.3.2 on Win2000 SP4 + all patches

Thanks,
Uwe

Jul 18 '05 #3

Now i tried it under Linux (Suse 8.2) + self compiled python 2.3.2.
It works!!
So, what the hell is going on with my stupid win2000?

Has anyone seen this before?

It think i'm going to reinstall the whole Shit.

Uwe
Uwe Grauer wrote:
Whats going on here.

Could someone please verify this?

I'm using python 2.3.2 on Win2000 SP4 + all patches

Thanks,
Uwe


Jul 18 '05 #4
Uwe Grauer <ne**@grauer-online.de> writes:
Now i tried it under Linux (Suse 8.2) + self compiled python 2.3.2.
It works!!
So, what the hell is going on with my stupid win2000?
maybe opening the file in binary mode helps (i.e. open(infile, "rb")) ?

Has anyone seen this before?

It think i'm going to reinstall the whole Shit.

Uwe
Uwe Grauer wrote:
Whats going on here.
Could someone please verify this?
I'm using python 2.3.2 on Win2000 SP4 + all patches
Thanks,
Uwe


--
brainbot technologies ag
boppstrasse 64 . 55118 mainz . germany
fon +49 6131 211639-1 . fax +49 6131 211639-2
http://brainbot.com/ mailto:ra**@brainbot.com
Jul 18 '05 #5
Uwe Grauer <ne**@grauer-online.de> wrote:
After playing around with the mailbox an email modules i noticed some
strange behaviours:

after the first message is parsed, i got some (kind of parsing errors).

My code:

def test_copy(infile, outfile):
from mailbox import UnixMailbox
from email import message_from_file as mff
try:
fd = open(infile, 'r')


Ralf is correct. The UnixMailbox method uses tell and seek to remember
file locations and return to them later. Tell and seek on Windows are only
valid with binary files; the \r\n to \n translation screws it up.

Change that to
fd = open(infile, 'rb')
and all will be well.
--
- Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Jul 18 '05 #6
Tim Roberts wrote:
Ralf is correct. The UnixMailbox method uses tell and seek to remember
file locations and return to them later. Tell and seek on Windows are only
valid with binary files; the \r\n to \n translation screws it up.


seek/tell works just fine on text files, as long as you only seek to
positions returned by tell (or to the beginning of the file). This is
standard ANSI C behaviour, btw.

(from a quick glance at the mailbox code, I cannot find any case
where the mailbox doesn't use seek/tell in this way, but I might be
missing something...)

</F>


Jul 18 '05 #7
Ralf Schmitt wrote:
Uwe Grauer <ne**@grauer-online.de> writes:

Now i tried it under Linux (Suse 8.2) + self compiled python 2.3.2.
It works!!
So, what the hell is going on with my stupid win2000?

maybe opening the file in binary mode helps (i.e. open(infile, "rb")) ?

Indeed, you are right.

Thanks
Uwe

Jul 18 '05 #8

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

Similar topics

1
by: Google Mike | last post by:
Tell me if this can be done, and if I have a misconception here. I am writing an app that will be served up in an app farm, and therefore I need to move the session information to the client, not...
12
by: Christoph Bergmann | last post by:
Hi... We want to write an open source web based TEXT editor and would be happy about any help ;-) Please notice: We do NOT want to write a web based WEB editor, where you can edit a web...
4
by: Mateo | last post by:
Hi! I have labels on my page (some are web forms controls, and some are plain HTML labels), and I need Mozilla compatibile way for reading label value. For example, in IE I can use this:...
4
by: Oliver Knoll | last post by:
According to my ANSI book, tmpfile() creates a file with wb+ mode (that is just writing, right?). How would one reopen it for reading? I got the following (which works): FILE *tmpFile =...
21
by: JoKur | last post by:
Hello, First let me tell you that I'm very new to C# and learning as I go. I'm trying to write a client application to communicate with a server (that I didn't write). Each message from the...
2
by: John Salerno | last post by:
I wrote this code just to experiment with writing to and reading from a file. It seems to work fine when writing, but when reading the file, it only prints the filepath to the screen, not the file...
3
by: Phil Endecott | last post by:
Dear All, I'm trying to read the content of the clipboard in a cross-browser way. Google will find various scripts such as this one: ...
5
by: UJ | last post by:
I have a system that has five programs that all communicate with each other via Message Queues. Works well. One program is a watchdog that will make sure the others are up and going. Currently I...
15
by: Cerebral Believer | last post by:
Hi all, I am a newbie to JavaScript and am just trying to get a script going that will write the ful date and time to each webpage as it is viewed. Can anyone point out what mistakes there are...
6
by: arne.muller | last post by:
Hello, I've come across some problems reading strucutres from binary files. Basically I've some strutures typedef struct { int i; double x; int n; double *mz;
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
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...
0
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,...
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.