clean mail queue exim

How to Clean the Mail Queue in Exim

Spread the love

In this tutorial, we will take a look at how we can clean our mail queue in Exim. Exim is a free and versatile mail transfer agent (MTA) that has been ported to most Unix-like systems and is currently the default for a few Linux distributions, most popular being the Debian Linux distribution. Exim is widely used around the world, and it is estimated that around 56% of the publicly available servers on the internet use Exim as their mail transfer agent.

Checking Exim’s mail queue

First let’s see if there are any specific messages we want to delete, type in the following command:

# exim -bp

This command lists all the messages in the queue with their respective message id’s, a message returned by this command looks like this:

18h 2.1K 1dMX7a-0001rT-I2 <> *** frozen ***
         root@somehost.com

The command to delete a message in Exim is:

# exim -Mrm <message-id>

So, if we want to delete the message in the example above we type in:

# exim -Mrm 1dMX7a-0001rT-I2

Cleaning Exim’s mail queue

Let’s say you have a lot of messages in your mail queue that were generated by a spam script and you want to clear your queue entirely without sending any messages, this can be done with:

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

As we’ve seen above, the first command (exim -bp) lists all the messages we have in the mail queue, the second command (exiqgrep -i) grabs only the message id’s from the first command and the third command (xargs exim -Mrm) passes the message id’s returned from the second command to the command (exim -Mrm) that is used to delete messages from the queue.

Sometimes you may have mail in the queue that is legitimate that the mail server couldn’t send because of various reasons and you may want to force the mail server to send this mail once the problem is resolved, this is done by using the following command:

# exim -qff

This will force Exim to send every message in the mail queue regardless of whether it is frozen or not.

That’s it, you have now successfully cleaned your mail queue.

Of course, you don’t have to do any of this if you use one of our Service Configuration & Optimization services, in which case you can simply ask our expert Linux admins to do this for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post, please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

One thought on “How to Clean the Mail Queue in Exim

Leave a Reply

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