Are your emails being automatically deleted from trash folder on cPanel server?

Trash; Source: freedigitalphotos.net

If you happen to run Courier IMAP server that comes with cPanel, then you are probably experiencing a rather unpleasant feature . By default, Courier will regularly delete every single email from trash folder that is more than 7 days old.

Considering that most people use IMAP protocol to keep their messages safe and always available on the server, this default option can cause a lot of frustration. Luckily, fixing this issue is rather easy and quick (it takes less than a minute).

First of all, if you are not the administrator of your cPanel server (ie. you have reseller or shared hosting account), then the rest of this tutorial will be useless for you. However, I encourage you to send the link to this article to your server administrator or technical support and kindly ask them to apply the modification described below 😄

So, there are two ways to disable automatic deletion of emails in trash folder. You can go to WHM > Service Configuration > Mailserver Configuration and uncheck IMAP Empty Trash setting.

Alternatively, you can log into the server via SSH, open Courier’s configuration file in /usr/lib/courier-imap/etc/imapd and simply delete the line IMAP_EMPTYTRASH=Trash:7

Then you will need to open /var/cpanel/courierconfig.yaml. This is the file where cPanel stores default settings that are applied on every rebuild of Courier’s configuration file. So, in courierconfig.yaml you should find the line that says imapd: and add IMAP_EMPTYTRASH: '' right below it (note that ’’ represent two single quotation marks).

Finally, to apply the change, you will need to restart Courier by executing

/scripts/restartsrv imap