How to Clear the Mail Queue on VPS or Dedicated Hosting
Have trouble with your emails getting stuck? It might be a mail queue issue. Don't worry; clearing the mail queue on your VPS or dedicated server is easier than you think. This guide will walk you through the process how to clear the mail queue step-by-step.
Click on any of these sections to jump to that point in the guide.
What You Need
- The password for the root user on your server.
- An SSH client like Terminal (Mac, Linux) or Putty (Windows).
- A domain name that points to your server or your server's IP address.
Login through SSH
Note: These instructions require knowing the root password for your server. If you don't know the root password or haven't set one up, please see Log in to WHM.
Using Terminal (Mac, Linux)
- Open Terminal
- Type the following command to log into your server through SSH:
ssh [email protected]
Note: Replace exampledomain.com with your domain or IP address. - If you receive a message about the authenticity of the host, type
yes
to continue connecting. - When it asks for your password, enter the root password to your server.
Note: It's normal not to see anything change on the screen as you enter your password.
Using Putty (Windows)
To make an SSH connection on Windows, you must have a compatible SSH client such as putty. You can download putty from http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html.
- Open Putty
- Enter your domain or IP address as the hostname.
- Enter 22 for the port number.
- The Protocol should be set to SSH.
- Click the Open button.
- If you receive a message about the authenticity of the host, type
yes
to continue connecting. - When it asks for the username, type
root
. - When it asks for the password, enter the root user's password.
Note: It's normal not to see anything change on the screen as you enter your password.
Clearing the Queue
Once you have logged into SSH as the root user, you will need to run a few commands to clear the queued mail files and the mail database.
Stopping the Mail System
Before clearing out the queue, it's a good idea to stop the mail system. This will take the mail system offline while you clean it up. Enter the following command to stop the mail service:
service exim stop
Clearing out the Files
After exim has stopped, enter the following command to clear out the mail files:
exim -bp | awk '{print $3}' | xargs exim -Mrm - removing *
Note: This command may take some time to run if you have a large queue. You will not be given any progress indicator but will see a list of the messages as they are being removed. You will know it's finished when the command prompt returns.
Clearing out the Database
- Stop the tailwatchd service by running this command:
/scripts/restartsrv_tailwatchd --stop
- Then, stop the eximstats by running the command:
/scripts/restartsrv_eximstats --stop
- Enter the following command to remove the mail stats database:
find /var/cpanel -name 'eximstats_db*' -exec rm {} +
- Run this command to restart the eximstats and recreate the mail stats database:
/scripts/restartsrv_eximstats
- Finally, enter this command:
/scripts/restartsrv_tailwatchd --start
Clearing out the Log
Clearing out the log will lower the file count, which may have spiked as a result of the excessively large mail queue. This is important because keeping your file count down will help your server perform better.
- Enter the following command to clear out the log:
rm -rf /var/spool/exim/msglog/*
Restart The Mail System
Enter the following command to start the mail system again.
service exim restart
Once the mail system has started, you will be finished clearing the queue.
Summary
And there you have it! You've successfully cleared your mail queue. Remember, a healthy mail queue is important for smooth, non-stop email delivery. With this simple process, the lost emails will now reach their destination, fine and dandy.
If you need further assistance, feel free to contact us via Chat or Phone:
- Chat Support - While on our website, you should see a CHAT bubble in the bottom right-hand corner of the page. Click anywhere on the bubble to begin a chat session.
- Phone Support -
- US: 888-401-4678
- International: +1 801-765-9400
You may also refer to our Knowledge Base articles to help answer common questions and guide you through various setup, configuration, and troubleshooting steps.