1. Home
  2. Linux
  3. General
  4. How to Clean the Mail Queue in Exim

How to Clean the Mail Queue in Exim

How to Clean the Mail Queue in Exim
How to Clean the Mail Queue in Exim

Exim is a free and versatile mail transfer agent (MTA) which was ported to many Unix-like systems and is the default for several Linux distributions, the most common of which is the Debian Linux distribution. Exim is used across the globe with around 56% of the publicly available servers on the internet using it as their mail transfer agent.
In the following tutorial, we are going to teach you how to clean the mail queue in Exim.

  1. How to install SquirrelMail on CentOS 7
  2. Linux Crontab: A Complete 5 minute tutorial

Checking Exim’s Mail Queue

Before we begin, we are going to check if there are any particular messages that we’d like to delete, execute the command below.

# exim -bp

This command should present a list of every message in the queue along with their respective message id.
A message returned by this command will look like the one below.

18h 2.1K 1dMX7a-0001rT-I2 <> *** frozen ***
         [email protected]

If you want to remove a message in Exim, use the following command.

# exim -Mrm <message-id>

If you would like to remove the message in the example above, you can execute the following command.

# exim -Mrm 1dMX7a-0001rT-I2

Clearing Exim’s Mail Queue

If you have several messages in your mail queue, which were generated by a spam script and you would like to get rid of them without sending any messages. So do the following as shown below.

# exim -bp | exiqgrep -i | xargs exim -Mrm

The first part of the command ‘Exim – bp’ lists every message we have in the mail queue.
The second command ‘exiqgrep –I’ retrieves only the message ids from the first command. Then the third command ‘xargs exim –Mrm’ passes the message ids returned from the second command to the command ‘exim –Mrm’. This in turn, deletes the messages from the queue.
You may find that you have mail in the queue which is legitimate. However,  that the mail server was not able to send due several reasons.
It is possible to force the mail server to send this mail once the problem has been fixed; this can be done by executing the following command.

# exim -qff

This should force Exim to send every message in the mail queue, regardless of whether it is frozen.
These are all of the things you should need to clean your mail queue completely.
Thanks;
Do let us know if you want to add any specific Linux VPS  hosting or Windows hosting topics into this tutorial series.

Updated on December 24, 2018

Was this article helpful?

Related Articles

Leave a Comment

[apsl-login-lite login_text='Please login with a social account']