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 <t...@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 some...@yourdomain.tld
<mailto:some...@yourdomain.tld> \( mailbox Trash or mailbox Junk \) savedBefore
30d
doveadm expunge -u someone_e...@youdomain.tld
<mailto: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.