[Tutor] How to get new messages from maildir?

chombee chombee at lavabit.com
Wed Nov 25 00:47:15 CET 2009


I'm using the standard mailbox module to read a maildir, but it seems to 
be quite difficult to do some simple things. Is there any way to 
identify a message as new, unread, unseen or something similar? What 
about finding the most recent message?

My aim is to write a program that will print out the From: and Subject: 
headers of new (or unread, or unseen, whatever I can get) messages, in 
chronological order. Or failing that, just print out all messages in 
chronological order.

As far as I can tell there's no way to do the first, and to do the 
second you would have to use the date strings in the messages, 
converting them to datetimes with strptime first, although on my system 
there doesn't seem to be a valid strftime format for python that matches 
the date strings in my emails. They end like "+0000 (GMT)", which I 
believe is "%z (%Z)" in strftime, but python will not accept the %z in 
the strftime pattern.



More information about the Tutor mailing list