Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

On a Debian Squeeze system I run an IMAP server using Dovecot with messages being stored in the Maildir format. The server is accessed by various clients, including Thunderbird, Evolution and RoundCube.

When a user deletes a message it is moved to the Trash folder. (I am unsure if all clients also mark the messages as deleted when moving them.) However, beyond that no action is taken. Hence I am forced to periodically remind all users to explicitly empty their Trash every few months.

Does Dovecot provide an easy means of automatically deleting Trashed messages older than n days? I've seen mention to an expunge cron-job but it seems to delete all messages older than a certain number of days as opposed to just those in Trash.

share|improve this question
up vote 2 down vote accepted

Expire plugin delete mails from specified mailboxes after a designated number of days.

share|improve this answer
That plugin just optimizes the existing process when you have thousands of users. It does not itself expunge old messages. – user9999999 Sep 24 '15 at 12:51

The Plugin that @hostemaster mentioned is not really needed if you don't deal with thousand of users.

Just create an easy script like this:


$DOVEADM expunge -A mailbox Trash savedbefore 90d
$DOVEADM expunge -A mailbox Junk  savedbefore 60d

And run it daily as an cronjob.

This will remove all messages from Trash that are older than 90 days, or from Junk if older than 60 days.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.