Expire plugin / expire-tool seems annoyingly inflexible currently, so I was thinking about a more generic redesign:
The expire plugin keeps track of the oldest message in configured mailboxes. Its only configuration is the list of tracked mailboxes. There's no configuration like what the expire timeouts are or anything.
There will be a new doveadm command:
doveadm expunge [-u user | -A] <mailbox> <search query>
So when you want to expunge all mails from Trash older than 1 week for all users, you say:
doveadm expunge -A Trash savedbefore 1w
This command works even without expire plugin. To optimize it to avoid looking into all users' Trash mailbox, there's a new expire doveadm plugin, which can use the expire dict to filter out users who don't have anything to expunge.
This also supports another feature that the plugin can optimize:
doveadm move -A INBOX Archive/2009/INBOX since 2009-01-01 before 2010-01-01
And since people have had problems waiting for expire dict to fill, there could be also a new parameter that does the filling immediately.
TODO:
dbox altmove feature will be removed from expire plugin. it may need another plugin, or some other way to configure expire plugin for it. it's anyway a special case.
When using multiple mailboxes it would be more optimal to handle all mailboxes for a user at once, rather than using separate doveadm commands. Maybe the command syntax needs some more thinking to support this. Different mailboxes could have different rules though..