a python script which will parse an email message

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Chuck Amadi

    a python script which will parse an email message


    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.getmb ox("/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



  • William Park

    #2
    Re: a python script which will parse an email message

    Chuck Amadi <chuck@smtl.co. uk> wrote:[color=blue]
    > for msg in mboxutils.getmb ox("/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[/color]

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

    --
    William Park, Open Geometry Consulting, <opengeometry@y ahoo.ca>
    Linux, Bash, Vim, TeX/LaTeX, Python, Mozilla, OpenOffice, Thin-Client

    Comment

    Working...