Python mail truncate problem
Wwy58 at yahoo.com
Mon May 18 11:13:58 EDT 2009
On May 18, 5:10 am, bieff... at gmail.com wrote:
> On 18 Mag, 05:51, David <Ww... at yahoo.com> wrote:
> > 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
> I have no idea about your problem. However, I believe that the last
> "mbox[key] = msg" is not needed. The objects returned by
> dict.iteritems are not copies but
> the actual ones in the dictionary, so your msg.add_flag() already
> modifies the object in mbox.
> FB- Hide quoted text -
> - Show quoted text -
thanks for your reply. If I delete "mbox[key] = msg", then the actual
files can not be updated for status.
More information about the Python-list