a python script which will parse an email message

C

Chuck Amadi

Hi Skip and all .

I have downloaded the module (mboxutils.py) from Spambayes project's mboxutils
module:

Thus created my script mailbox.py

Had a look at especially the getmbox() function.
And tried to use as So .

#!/usr/bin/env python


#Import statement used to import external modules
import mboxutils
#Existing file a Unix-style mailbox
for msg in mboxutils.getmbox("/var/spool/mail/chucka"):
print msg['subject']
print msg['body']


I need just the Subject and Body of the all mail messages in the above Mail
folder
Runs but no output So I know its' done something as when I use another user
mailbox
it produces an error permission denied . So basically how do I see the output
result and thus I can process it to One File.

Im digesting the mboxutils.py but I assume that as an external module I just
load it using the import statement as above

Cheers

Chuck
 
W

William Park

Chuck Amadi said:
for msg in mboxutils.getmbox("/var/spool/mail/chucka"):
print msg['subject']
print msg['body']

I need just the Subject and Body of the all mail messages in the above Mail
folder

Assuming it's not homework,
formail -X From: -X Subject: -s < /var/spool/mail/chucka
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top