[Dovecot] There is a way to know if a email has been expunged ?

Timo Sirainen tss at iki.fi
Sun Feb 12 06:19:38 EET 2012

On 10.2.2012, at 19.39, Alex Baule wrote:

> Hy Everyone...and Timo !
> There is a way to know if a email was expunged (deleted from hard
> disk)  inside a plugin ? I rewrite the expunge function, but the real
> expunge function is void, i can't know if was really expunged.
> There is a way to know this ?

It's not known until transaction_commit() what messages are expunged. What do you need to know this for? There are a few different ways.

If you simply need one of the sessions to definitely know that it expunged a message, you can do it like quota plugin does. (So even if there are multiple clients doing EXPUNGE at the same time, quota is never decreased more than once per mail.) See quota-storage.c and most importantly quota_mailbox_sync_notify().

Quota code also shows the other method of doing it: keep track of what mail_expunge()s have been called, and then in transaction commit check if it succeeds and if it does do what you want to do.

More information about the dovecot mailing list