autoexpunge - different settings for different users
I have some users where I'd like to expunge their mail at different times.
For example, I may have some users who I want to expunge everything from every folder at 30 days.
Others where I'd like to expunge everything at 90 days.
And still others where I only want to expunge mail from the Trash and Junk folders, and nowhere else.
Is there a way to do some sort of lookup for this? Or is this beyond the ability of the autoexpunge feature? Should I just use a cron job and use "doveadm expunge" on a user-by-user basis?
Thanks-
On 7 Feb 2016, at 02:50, Tom Johnson <tj@terramar.net> wrote:
I have some users where I'd like to expunge their mail at different times.
For example, I may have some users who I want to expunge everything from every folder at 30 days.
Others where I'd like to expunge everything at 90 days.
And still others where I only want to expunge mail from the Trash and Junk folders, and nowhere else.
Is there a way to do some sort of lookup for this? Or is this beyond the ability of the autoexpunge feature? Should I just use a cron job and use "doveadm expunge" on a user-by-user basis?
Thanks-
I think you’ll need a script for this. At the most basic level you could just create a bash script, add a bunch of expunge commands and then run it every day (or week or whatever) via crontab. For example:
doveadm expunge -u someone@yourdomain.tld <mailto:someone@yourdomain.tld> \( mailbox Trash or mailbox Junk \) savedBefore 30d
doveadm expunge -u someone_else@youdomain.tld <mailto:someone_else@youdomain.tld> savedBefore 90d
And so-on. Also, don’t forget to add a purge command if you’re using the mdbox format, in my case I’d add this to the start of the script, so messages aren’t purged right away (i.e- expunged messages are not purged until the next time the script runs), but this only applies to that format.
More complex logic will require a more complex script, I’ve been working on something of my own but I don’t know if I’d call it ready yet, and I’m not aware of anything else pre-made that will do it, but hopefully others can weigh in if there is.
On 7 Feb 2016, at 10:17, Haravikk <dovecot@haravikk.me> wrote:
On 7 Feb 2016, at 02:50, Tom Johnson <tj@terramar.net> wrote:
I have some users where I'd like to expunge their mail at different times.
For example, I may have some users who I want to expunge everything from every folder at 30 days.
Others where I'd like to expunge everything at 90 days.
And still others where I only want to expunge mail from the Trash and Junk folders, and nowhere else.
Is there a way to do some sort of lookup for this? Or is this beyond the ability of the autoexpunge feature? Should I just use a cron job and use "doveadm expunge" on a user-by-user basis?
Thanks-
I think you’ll need a script for this. At the most basic level you could just create a bash script, add a bunch of expunge commands and then run it every day (or week or whatever) via crontab. For example:
doveadm expunge -u someone@yourdomain.tld <mailto:someone@yourdomain.tld> \( mailbox Trash or mailbox Junk \) savedBefore 30d doveadm expunge -u someone_else@youdomain.tld <mailto:someone_else@youdomain.tld> savedBefore 90d
And so-on. Also, don’t forget to add a purge command if you’re using the mdbox format, in my case I’d add this to the start of the script, so messages aren’t purged right away (i.e- expunged messages are not purged until the next time the script runs), but this only applies to that format.
More complex logic will require a more complex script, I’ve been working on something of my own but I don’t know if I’d call it ready yet, and I’m not aware of anything else pre-made that will do it, but hopefully others can weigh in if there is.
Just a note, but please disregard the extra e-mail in the angle brackets, OS X’s Mail seems to have added these automatically, the sample commands should look like:
doveadm expunge -u someone@yourdomain.tld \( mailbox Trash or mailbox Junk \) savedBefore 30d
doveadm expunge -u someone_else@youdomain.tld savedBefore 90d
If have a Bash script I invoke from cron that iterates thru /home looking for a control file in each users Maildir that looks like this: /home/bill/Maildir/maildir.dovecot.purge.conf #Mailbox : KeepDays # -------------------------------------------------------- #INBOX : 180 #INBOX* : 180 #Invoices sent : 14 Trash* : 14 Junk : 14 Sent : 14 Sent Messages : 14 SystemFolders.SuspectedSpam : 14 #SystemFolders* : 14 #SystemFolders.* : 14 #AASystemAdministration : 14
Let me know if you're interested in the script. [1:root@elmo vhosts]$ wc -l /usr/local/sbin/maildir.dovecot.purge 82 /usr/local/sbin/maildir.dovecot.purge
Bill
On 2/7/2016 5:17 AM, Haravikk wrote:
On 7 Feb 2016, at 02:50, Tom Johnson <tj@terramar.net> wrote:
I have some users where I'd like to expunge their mail at different times.
For example, I may have some users who I want to expunge everything from every folder at 30 days.
Others where I'd like to expunge everything at 90 days.
And still others where I only want to expunge mail from the Trash and Junk folders, and nowhere else.
Is there a way to do some sort of lookup for this? Or is this beyond the ability of the autoexpunge feature? Should I just use a cron job and use "doveadm expunge" on a user-by-user basis?
Thanks- I think you’ll need a script for this. At the most basic level you could just create a bash script, add a bunch of expunge commands and then run it every day (or week or whatever) via crontab. For example:
doveadm expunge -u someone@yourdomain.tld <mailto:someone@yourdomain.tld> \( mailbox Trash or mailbox Junk \) savedBefore 30d doveadm expunge -u someone_else@youdomain.tld <mailto:someone_else@youdomain.tld> savedBefore 90d
And so-on. Also, don’t forget to add a purge command if you’re using the mdbox format, in my case I’d add this to the start of the script, so messages aren’t purged right away (i.e- expunged messages are not purged until the next time the script runs), but this only applies to that format.
More complex logic will require a more complex script, I’ve been working on something of my own but I don’t know if I’d call it ready yet, and I’m not aware of anything else pre-made that will do it, but hopefully others can weigh in if there is.
On 07 Feb 2016, at 04:50, Tom Johnson <tj@terramar.net> wrote:
I have some users where I'd like to expunge their mail at different times.
For example, I may have some users who I want to expunge everything from every folder at 30 days.
Others where I'd like to expunge everything at 90 days.
And still others where I only want to expunge mail from the Trash and Junk folders, and nowhere else.
Is there a way to do some sort of lookup for this? Or is this beyond the ability of the autoexpunge feature? Should I just use a cron job and use "doveadm expunge" on a user-by-user basis?
You can override any mail-related setting from userdb. So for example if you have:
namespace inbox { mailbox Trash { autoexpunge = 30d } }
You can have your userdb return namespace/inbox/Trash/autoexpunge=90d extra field for other users. http://wiki2.dovecot.org/UserDatabase/ExtraFields has some examples.
On Feb 7, 2016, at 10:59 AM, Timo Sirainen <tss@iki.fi> wrote:
On 07 Feb 2016, at 04:50, Tom Johnson <tj@terramar.net> wrote:
I have some users where I'd like to expunge their mail at different times. .... .... Is there a way to do some sort of lookup for this? Or is this beyond the ability of the autoexpunge feature? Should I just use a cron job and use "doveadm expunge" on a user-by-user basis?
You can override any mail-related setting from userdb. So for example if you have:
namespace inbox { mailbox Trash { autoexpunge = 30d } }
You can have your userdb return namespace/inbox/Trash/autoexpunge=90d extra field for other users. http://wiki2.dovecot.org/UserDatabase/ExtraFields has some examples.
Thank you, Timo!
Can you return something like "namespace/inbox/*/autoexpuge=90d" to cover all the namespaces? And then override individual ones if necessary?
On 08 Feb 2016, at 06:46, Tom Johnson <tj@terramar.net> wrote:
You can override any mail-related setting from userdb. So for example if you have:
namespace inbox { mailbox Trash { autoexpunge = 30d } }
You can have your userdb return namespace/inbox/Trash/autoexpunge=90d extra field for other users. http://wiki2.dovecot.org/UserDatabase/ExtraFields has some examples.
Thank you, Timo!
Can you return something like "namespace/inbox/*/autoexpuge=90d" to cover all the namespaces? And then override individual ones if necessary?
It would mean the same as:
namespace inbox { mailbox * { autoexpunge = 90d } }
So the question is about whether the above configuration works. Currently it doesn't, but it probably will in future.
On Feb 8, 2016, at 2:02 AM, Timo Sirainen <tss@iki.fi> wrote:
On 08 Feb 2016, at 06:46, Tom Johnson <tj@terramar.net> wrote:
Can you return something like "namespace/inbox/*/autoexpuge=90d" to cover all the namespaces? And then override individual ones if necessary?
It would mean the same as:
namespace inbox { mailbox * { autoexpunge = 90d } }
So the question is about whether the above configuration works. Currently it doesn't, but it probably will in future.
Does this mean that you can't use autoexpunge on the main inbox for a user at all?
On Feb 7, 2016, at 10:59 AM, Timo Sirainen <tss@iki.fi> wrote:
You can override any mail-related setting from userdb. So for example if you have:
namespace inbox { mailbox Trash { autoexpunge = 30d } }
You can have your userdb return namespace/inbox/Trash/autoexpunge=90d extra field for other users. http://wiki2.dovecot.org/UserDatabase/ExtraFields has some examples.
I have my query returning the extra field, with the namespace entries separated by tabs. If I do a doveadm, I see it: # doveadm user <xxx> field value uid 1005 gid 1005 home <xxx> mail <xxx> namespace/inbox/Drafts/autoexpunge 3d namespace/inbox/Quarantine/autoexpunge 3d quota_rule *:storage=10000M
I turned on debugging, and tried to deliver some email to see if autoexpunge is called, and I'm seeing this:
2016-02-09T01:41:23+0000 s01.lax.mailroute.net dovecot: doveadm(tj@terramar.net): Debug: Unknown userdb setting: plugin/namespace/inbox/Drafts/autoexpunge=3d
2016-02-09T01:41:23+0000 s01.lax.mailroute.net dovecot: doveadm(tj@terramar.net): Debug: Unknown userdb setting: plugin/namespace/inbox/Quarantine/autoexpunge=3d
Anybody know what am I missing?
Thanks-
Tom
Hi Tom,
Looks like you are missing 'mailbox' keyword:
namespace/inbox/mailbox/Drafts/autoexpunge=3d
Regards,
Leon
On Tue, Feb 9, 2016 at 12:51 PM Tom Johnson <tj@terramar.net> wrote:
On Feb 7, 2016, at 10:59 AM, Timo Sirainen <tss@iki.fi> wrote:
You can override any mail-related setting from userdb. So for example if you have:
namespace inbox { mailbox Trash { autoexpunge = 30d } }
You can have your userdb return namespace/inbox/Trash/autoexpunge=90d extra field for other users. http://wiki2.dovecot.org/UserDatabase/ExtraFields has some examples.
I have my query returning the extra field, with the namespace entries separated by tabs. If I do a doveadm, I see it: # doveadm user <xxx> field value uid 1005 gid 1005 home <xxx> mail <xxx> namespace/inbox/Drafts/autoexpunge 3d namespace/inbox/Quarantine/autoexpunge 3d quota_rule *:storage=10000M
I turned on debugging, and tried to deliver some email to see if autoexpunge is called, and I'm seeing this:
2016-02-09T01:41:23+0000 s01.lax.mailroute.net dovecot: doveadm(
tj@terramar.net): Debug: Unknown userdb setting: plugin/namespace/inbox/Drafts/autoexpunge=3d 2016-02-09T01:41:23+0000 s01.lax.mailroute.net dovecot: doveadm( tj@terramar.net): Debug: Unknown userdb setting: plugin/namespace/inbox/Quarantine/autoexpunge=3d
Anybody know what am I missing?
Thanks-
Tom
participants (5)
-
Bill Shirley
-
Haravikk
-
Leon Kyneur
-
Timo Sirainen
-
Tom Johnson