> On 28 Jan 2016, at 17:51, Haravikk <dove...@haravikk.me> wrote: > > So I’m looking at setting up some house-keeping for my dovecot mailboxes, > specifically deleting messages in trash, spam etc., by deleting Seen messages > older than X days. > > In order to protect against the edge case of a user reading a message right > before the deletion task however I’d like to do something like the following: > > doveadm expunge -A OLD SEEN BEFORE 7d MAILBOX Trash > doveadm flags -A remove '\Recent' SEEN BEFORE 7d MAILBOX Trash > (except I’m actually doing this per-user with a script and per-user settings > for flexibility, but you get the idea) > > Basically the expunge step only deletes messages without the Recent flag (and > which haven’t been marked as unseen again). It then removes this flag from > messages which have been seen, so that they will be deleted next time the > expunge command runs. In other words, if this command runs once a day, there > will be a minimum delay of 24 hours between a message being seen, and then > being deleted. > > However I can’t for the life of me figure out how to set the Recent flag > except via doveadm flags. While I could periodically run doveadm -A flags add > ‘\Recent’ SEEN or such this doesn’t seem like a great way to do it (adding > the flag after the messages are stored), really I’d rather do it as they > arrive. I’ve tried sieve, but it can’t set this flag. > > Have I managed to completely miss an option for setting this when new > messages arrive?
\Recent flag is special and you can't add/remove it. It's not even internally stored like regular flags. I think what you want instead is: doveadm expunge -A old seen savedbefore 7d mailbox Trash The savedbefore timestamp is updated whenever a mail is added to Trash.