How to Clear the Default Mail Account on a cPanel Server

Each domain in cPanel has a default mail account configured with the account username. This mail account is used for all the notifications from the server. Also, if the catch-all feature is enabled, all non-existing emails are routed to it.

Spam is often sent to randomly generated or common mailboxes (eg. info@) and if they are are not configured under your cPanel it will end up in the default mailbox. This will eventually take up a lot of disk space and there may be the need to clear this space to avoid the account filling up.

Default Mailbox Locations

There are two directories that need to be cleared under the default mail account. These are the cur and new directories located in the following locations

/home/username/mail/cur

and

/home/username/mail/new

Clearing these directories will free up disk space on the default mailboxes.

Clear Mails with SSH in the Terminal

Run the following commands in the terminal to delete all recurring mail items in the default mailboxes

$ rm -rf /home/username/mail/cur/*
$ rm -rf /home/username/mail/new/*

The above command stipulates the following:

  • rm is the command to remove/delete items.
  • -r for recursive removal (typically used with directories)
  • -f to force the action
  • -rf is to simply join the two options joined together.

Note: Always check your commands before running in a terminal

Disk Quota

It is important to note that the disk quota will not actually change after removing the mails from the cur and new directories as cPanel caches these values. There is maildirsize file that needs to be deleted or renamed but will automatically be generated again with the correct values.

To delete the file run the following command:

$ rm -rf /home/username/mail/maildirsize

To rename the file run the following command

$ mv /home/username/mail/maildirsize  /home/username/mail/maildirsize.old

Clear Mails with File Manager

The above operations can also be done with cPanel’s File Manager. Navigate to the above locations to delete the files in the cur and new directories, and to delete or rename the maildirsize file.

Disable Catch-All Feature in WHM

The server administrator will be able to disable the Catch-All Feature in WHM by doing the following:

  1. Navigate to WHM > Server Configuration > Tweak Settings > Mail
  2. Set the value of the field ‘Initial default/catch-all forwarder destination’ to fail

Check the Disk Space

Check the disk space usage to see if the mails has been removed. To see disk usage, navigate to cPanel > Disk Usage

Share this article

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to Top