Re: autoexpunge - different settings for different users

2016-02-07 Thread Haravikk

> On 7 Feb 2016, at 02:50, Tom Johnson  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 some...@yourdomain.tld 
 \( mailbox Trash or mailbox Junk \) savedBefore 
30d
doveadm expunge -u someone_e...@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.

Re: autoexpunge - different settings for different users

2016-02-07 Thread Haravikk

> On 7 Feb 2016, at 10:17, Haravikk  wrote:
> 
> 
>> On 7 Feb 2016, at 02:50, Tom Johnson  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 some...@yourdomain.tld 
>  \( mailbox Trash or mailbox Junk \) 
> savedBefore 30d
>   doveadm expunge -u someone_e...@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 some...@yourdomain.tld \( mailbox Trash or mailbox 
Junk \) savedBefore 30d
doveadm expunge -u someone_e...@youdomain.tld savedBefore 90d

Re: autoexpunge - different settings for different users

2016-02-07 Thread Bill Shirley
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  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 some...@yourdomain.tld 
 \( mailbox Trash or mailbox Junk \) savedBefore 
30d
doveadm expunge -u someone_e...@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.


Re: autoexpunge - different settings for different users

2016-02-07 Thread Timo Sirainen

> On 07 Feb 2016, at 04:50, Tom Johnson  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.


Re: autoexpunge - different settings for different users

2016-02-07 Thread Tom Johnson

> On Feb 7, 2016, at 10:59 AM, Timo Sirainen  wrote:
>> On 07 Feb 2016, at 04:50, Tom Johnson  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?