I've written some code in python that opens the Maildir, updates "new" messages to be in "cur", flushes and closes the mail dir. The problem is that when I read the very same Maildir again after this using the script, it's still reading all emails as new!
(if I actually have a look in the OS directly, I can the see that the mail files have been moved from Maildir/new to Maildir/cur)
Any ideas?
mail = Maildir(self._mail_dir, factory=MaildirMessage)
mail.lock()
for i, (key, m) in enumerate(mail.iteritems()):
if m.get_subdir() == "new":
m.set_subdir("cur")
m.add_flag("S") # Message seen
mail[key] = m
do_something_else(m)
mail.flush()
mail.close()
Thanks in advance!
Finally found the fix. Basically I only need to pass factory=None instead of factory=MaildirMessage.
Reading the documentation in the link below it seems like factory=None actually picks MaildirMessage factory but apparently it also adds extra behavior.