[Dovecot] finding messages deleted before timespec

Joseph Tam jtam.home at gmail.com
Wed Sep 5 02:02:44 EEST 2012


On Tue, 4 Sep 2012, Sven Hartge wrote:

> I am searching for a search_query which only matches messages with the
> flag \Deleted whose flag has been set 24h or longer ago.
>
> Doing something like
>
>  doveadm expunge -A mailbox \* DELETED
>
> is not the solution, since it will expunge all deleted mails without
> looking at the time when they have been deleted.
>
> Using savedbefore does not work either, since a message may have been
> saved 2 years ago but only recently deleted.

You could work out a cron job that does a "doveadm search ...", then diff
it with one generated 24 hours ago, extract the common GID/UUIDs, then do a
second pass to delete them.

Not elegant, but it would probably work.

(I just read the man page, and there doesn't seem to be an option
to pipe the search like "doveadm search ... | doveadm expunge ...".
You'll have to expunge one message at a time.  Ugh.)

Or maybe the advice "don't worry, be happy" applies here.  I find that
too many "mistake mitigation" features is counterproductive as users
habitually relying on them, rather than being careful.  Extending your
grace period to a week will lessen the probability of this race condition.

Joseph Tam <jtam.home at gmail.com>



More information about the dovecot mailing list