Can I get message filename from a Maildir mailbox stream?

Michael Josephson mikej at well.com
Sat Feb 19 05:36:51 EST 2005


>a way to figure out what filename an email object points to in a 
>qmail style Maildir directory?

Assuming you're using the mailbox module from the standard Python
library, the Message objects you get back provide access to the file
object as an instance variable called fp. So if you have:

maildir = mailbox.Maildir("/home/mike/Maildir")
message = maildir.next()

The filename is message.fp.name

Note that the file object is open when you are in this state so you
may want to close it before you do a move/delete etc.

-Michael



More information about the Python-list mailing list