[Help]: mailbox classes
jdavis at empires.org
Thu Sep 19 08:36:34 CEST 2002
Ok, I'll assume your using mbox format, but this is easily adapted for
mbox_file = '/path/to/mbox'
mbox_fp = open(mbox_file)
mbox = mailbox.UnixMailbox(mbox_fp)
msg = mbox.next()
there, now you have a message object (a rfc822.Message object, to be
exact). Now just import the rfc822 module and do whatever you need. You'll
probably want to use a loop to process all of the messages.
> 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.
More information about the Python-list