[Help]: mailbox classes
huaiyu at gauss.almadan.ibm.com
Fri Sep 20 20:34:41 CEST 2002
J. Li <jylimd at yahoo.com> wrote:
>I am trying to extract a message from a unix mailbox file. Python does
>provide few classes for easy and uniform access. So it says! After
>having read the libiary references, I went nowhere.
>Can anyone give me an example as how to use these mailbox classes and
>what is it relationship with email.message classes.
I just figured this out yesterday following examples in spambayes project.
The documentation is very fuzzy, but this works for me:
from mailbox import PortableUnixMailbox as MB
from email import message_from_file as get_msg
return MB(file(mfile), get_msg)
if __name__ == '__main__':
mbox = get_mbox('test.mail')
msgs = list(mbox)
msg = msgs
More information about the Python-list