Automatic purging of old email in all mailboxes
Joseph Tam
jtam.home at gmail.com
Mon Aug 29 20:13:18 UTC 2016
"Scott W. Sander" <scottwsx96 at gmail.com> writes:
> A few of the mailboxes in Dovecot receive hundreds of emails per day. I'd
> like to automatically remove all emails in all mailboxes and mailbox
> folders that were received more than 90 days prior to the received date.
> As I'm a novice Dovecot administrator, I'm not exactly sure what the best
> way to accomplish this is, but I've started looking at the "doveadm
> expunge" command. I figure I could create a cron job that calls this
> command with the -A switch and that has a search query that finds all
> emails older than 90 days.
That more of less what I do.
doveadm expunge -A mailbox INBOX savedbefore 7d
> Error: User listing returned failure
> doveadm: Error: Failed to iterate through some users
I think this may be avoided (or made into warnings) if you bracket all
user UID ranges with
first_valid_uid = {first user uid}
last_valid_uid = {last user uid}
Sean Greenslade <sean at seangreenslade.com> then writes:
> Since you're using maildirs as the storage backend, it might be easier
> to just write a small script in the language of your preference (bash,
> python, perl, etc.) that walks the directory tree and deletes files
> based on their mtime.
The downside is that the Dovecot caches will be out of date. Perhaps
follow this up with a "doveadm index ..." operation.
Joseph Tam <jtam.home at gmail.com>
More information about the dovecot
mailing list