deleting a message with imaplib

Donn Cave donn at
Mon Aug 19 11:21:35 EDT 2002

Quoth Gerhard Hring <gerhard.haering at>:
| Am I blind or does Python's imaplib really have no means of deleting a
| message on the IMAP server? Anybody knows a patch or a workaround?

You are blind!  OK, it isn't the most obvious thing.  IMAP deletes
in two stages:  first, set the Deleted flag, then you can issue an
EXPUNGE command that rewrites the folder and leaves out the Deleted
messages (assuming exclusive access.)

  ok, detail ='5', '+Flags', '(\Deleted)')
  ok, detail = imap.expunge()

	Donn Cave, donn at

More information about the Python-list mailing list