a python script which will parse an email message

Skip Montanaro skip at pobox.com
Thu May 27 21:28:58 EDT 2004


    chuck> any python script which will parse an email messages into a file
    chuck> to poplulate a database.  Im trying with UnixMailbox but I cant
    chuck> figure out howto abstract the all email data messages to a file .

Take a look at the Spambayes project's mboxutils module:

    http://cvs.sourceforge.net/viewcvs.py/spambayes/spambayes/spambayes/mboxutils.py

especially the getmbox() function.  You'd use it like so:

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

Skip




More information about the Python-list mailing list