autoexpunge - different settings for different users
Haravikk
dovecot at haravikk.me
Sun Feb 7 11:28:05 UTC 2016
> 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
More information about the dovecot
mailing list