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 at 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 at yourdomain.tld <mailto:someone at yourdomain.tld> \( mailbox Trash or mailbox Junk \) savedBefore 30d doveadm expunge -u someone_else at youdomain.tld <mailto:someone_else at 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 at haravikk.me> wrote: > > >> On 7 Feb 2016, at 02:50, Tom Johnson <tj at 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 at yourdomain.tld <mailto:someone at yourdomain.tld> \( mailbox Trash or mailbox Junk \) savedBefore 30d > doveadm expunge -u someone_else at youdomain.tld <mailto:someone_else at 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 at yourdomain.tld \( mailbox Trash or mailbox Junk \) savedBefore 30d doveadm expunge -u someone_else at 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 at 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 at 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 at yourdomain.tld <mailto:someone at yourdomain.tld> \( mailbox Trash or mailbox Junk \) savedBefore 30d > doveadm expunge -u someone_else at youdomain.tld <mailto:someone_else at 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 at 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 at iki.fi> wrote: >> On 07 Feb 2016, at 04:50, Tom Johnson <tj at 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 Feb 7, 2016, at 10:59 AM, Timo Sirainen <tss at 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 at 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 at terramar.net): Debug: Unknown userdb setting: plugin/namespace/inbox/Quarantine/autoexpunge=3d Anybody know what am I missing? Thanks- Tom