Setting Recent Flag on New Messages?
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?
Am 28.01.2016 um 16:51 schrieb Haravikk:
I’ve tried sieve, but it can’t set this flag.
imapflags muss be added in 90-sieve.conf like
sieve_extensions = +notify +imapflags +editheader
from short sight on
https://tools.ietf.org/html/rfc5232
i found no reason why it shouldnt work, but Stephan Bosch should be the best man to answer it
Best Regards MfG Robert Schetterer
-- [*] sys4 AG
http://sys4.de, +49 (89) 30 90 46 64 Franziskanerstraße 15, 81669 München
Sitz der Gesellschaft: München, Amtsgericht München: HRB 199263 Vorstand: Patrick Ben Koetter, Marc Schiffbauer Aufsichtsratsvorsitzender: Florian Kirstein
On 28 Jan 2016, at 16:55, Robert Schetterer <rs@sys4.de> wrote:
Am 28.01.2016 um 16:51 schrieb Haravikk:
I’ve tried sieve, but it can’t set this flag.
imapflags muss be added in 90-sieve.conf
Oh I can set other flags, but \Recent seems to be specifically disallowed in the specification that you linked to:
"Note that it is not possible to use this extension to set or clear the \Recent flag or any other special system flag that is not settable in [IMAP].”
Or does the deprecated imapflags allow it where imap4flags does not? It doesn’t seem like I should really have to rely on a deprecated sieve extension though.
On 28 Jan 2016, at 17:51, Haravikk <dovecot@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.
On 29 Jan 2016, at 14:29, Timo Sirainen <tss@iki.fi> wrote:
\Recent flag is special and you can't add/remove it. It's not even internally stored like regular flags.
Are you certain? The following commands seem to work just fine:
doveadm flags add -A ‘\Recent’ OLD UNSEEN
doveadm search -A NEW
Before I ran the first command, the second wouldn’t return anything, so \Recent does seem to be set via doveadm flags, doveadm fetch flags also seems to confirm this.
I think what you want instead is:
doveadm expunge -A old seen savedbefore 7d mailbox Trash
While you’re right that I should probably be using saved before, I’m trying to find an alternative to this specific command because it seems like it would be possible for a message that’s 7 days old to potentially to be opened by the user such that is flagged as seen, but is actually still being read when the command is run, allowing it to be expunged before the user has a chance to do anything with it. Or is the saved before value updated when flags are changed?
On 29 Jan 2016, at 17:09, Haravikk <e-mail@haravikk.me> wrote:
On 29 Jan 2016, at 14:29, Timo Sirainen <tss@iki.fi> wrote:
\Recent flag is special and you can't add/remove it. It's not even internally stored like regular flags.
Are you certain? The following commands seem to work just fine:
doveadm flags add -A ‘\Recent’ OLD UNSEEN doveadm search -A NEW
Before I ran the first command, the second wouldn’t return anything, so \Recent does seem to be set via doveadm flags, doveadm fetch flags also seems to confirm this.
I don't know how that would be possible.
I think what you want instead is:
doveadm expunge -A old seen savedbefore 7d mailbox Trash
While you’re right that I should probably be using saved before, I’m trying to find an alternative to this specific command because it seems like it would be possible for a message that’s 7 days old to potentially to be opened by the user such that is flagged as seen, but is actually still being read when the command is run, allowing it to be expunged before the user has a chance to do anything with it. Or is the saved before value updated when flags are changed?
There are no timestamps that are updated when a message flags are changed. I suppose if you have a nightly cronjob you could run:
doveadm expunge -A keyword seen-yesterday mailbox Trash doveadm flags add -A 'seen-yesterday' seen savedbefore 7d mailbox Trash
So it guarantees that the \Seen flag was added at least the day before.
participants (4)
-
Haravikk
-
Haravikk
-
Robert Schetterer
-
Timo Sirainen