Are your email users running out of space even though their inboxes are empty? The culprit is often the Trash folder, where deleted emails quietly pile up. By default, Courier-IMAP may be configured to automatically delete emails in the Trash folder after 7 days.

In this post, we’ll show you how to disable or change this setting on your server, ensuring no emails are deleted from Trash unless the user manually clears them.


πŸ“Œ Why This Matters

On shared or corporate mail servers, automatic trash deletion can be helpful to keep storage usage in check. But sometimes, important emails might remain in Trash longer than 7 days β€” and get deleted unexpectedly.

Disabling this setting gives users more control over their email retention.

🧰 Step-by-Step: Disable Auto Trash Purge in Courier-IMAP

βœ… Step 1: Log in via SSH

Use root access to log into your server:

ssh root@your-server-ip

βœ… Step 2: Edit the Courier-IMAP Configuration

Open the imapd configuration file in your favorite editor (we’ll use vi here):

vi /usr/lib/courier-imap/etc/imapd

βœ… Step 3: Locate the Auto Trash Purge Setting

Search for the line that begins with:

IMAP_EMPTYTRASH

It may look like this:

IMAP_EMPTYTRASH=Trash:7
This means emails in the Trash folder are automatically deleted after 7 days.

βœ… Step 4: Disable or Modify the Setting
To disable auto-deletion, simply comment it out by adding a # in front of the line:

#IMAP_EMPTYTRASH=Trash:7

Alternatively, you can set it to a different number of days (e.g., 30 days):

IMAP_EMPTYTRASH=Trash:30

βœ… Step 5: Restart Courier-IMAP

Apply the changes by restarting the Courier-IMAP service:

service courier-imap restart

πŸŽ‰ You’re Done!

Now, emails in the Trash folder will no longer be deleted automatically after 7 days, unless you’ve set a different time limit.

This gives your users more flexibility and avoids accidental email loss due to hidden auto-cleanup settings.

🧠 Pro Tip:

Encourage users to manually empty their Trash folders periodically to manage space usage, especially on shared servers.

By admin