Python mail truncate problem

David Wwy58 at yahoo.com
Sun May 17 23:51:44 EDT 2009


Hi,

I am writing Python script to process e-mails in a user's mail
account. What I want to do is to update that e-mail's Status to 'R'
after processing it, however, the following script truncates old e-
mails even though it updates that e-mail's Status correctly. Anybody
knows how to fix this?

Thanks so much.

  fp = '/var/spool/mail/' + user
                mbox = mailbox.mbox(fp)

                for key, msg in mbox.iteritems():
                        flags = msg.get_flags()

                        if 'R' not in flags:
                                # now process the e-mail
                                # now update status
                                msg.add_flag('R' + flags)
                                mbox[key] = msg




More information about the Python-list mailing list