Access maildir inbox from Python

317 Views Asked by At

How do I access messages in the top-level folder of a maildir in Python?

The top-level folder does not show iup in list_folders(), and iterating over the messages gives me messages in all folders, which I don't want.

import mailbox
import os
dirpath = os.path.join(os.environ['HOME'], 'Maildir')
mbox = mailbox.Maildir(dirpath, create=False)

print(mbox.list_folders())    # Top-level folder does not show up
folder = mbox.get_folder(???) # What do I put here?
for msg in folder.itervalues():
    ...
0

There are 0 best solutions below