more python problems

Jan 04, 2008 15:44

I have an email application that generates a big file of all the emails ever received by each person. I am using python's email.Parser module to read the big file and process each message later for logging purposes. All emails generated via the web email application are multi-part, and when I parse the big file, it turns the first email into a ( Read more... )

Leave a comment

Comments 3

arcanology January 4 2008, 21:21:15 UTC
It sounds like what you want the parser to do is just drop system messages on the floor. I'd read the source and look into either modifying your local copy to Do What You Want directly or (since that's probably hard on a built-in module) modifying it in the running program by just redefining one of its methods...

Also have a look around the net for other python mail handlers or people with the same problem.

Reply


dzm January 4 2008, 21:41:17 UTC
The online Python library message includes a mailbox module, which sounds like its a little closer to what you want.

import mailbox
f = open('mailfile','r')
box = mailbox.mbox(f)
for message in box:
# message is an email.Message
pass

Some more examples here.

Reply

nuclearpolymer January 4 2008, 23:08:10 UTC
This is an even dumber question, but my python does not seem to have the mailbox module that you mentioned. It seems to have a different mailbox module. Is it possible to switch them? I am running 2.4 I think.

Reply


Leave a comment

Up