Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!

Author Topic: How to Clean the Mail Queue in Exim  (Read 1800 times)

0 Members and 1 Guest are viewing this topic.

joseletk

  • Guest
How to Clean the Mail Queue in Exim
« on: March 16, 2018, 05:55:17 am »
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.

Checking Exim’s mail queue

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

Code: [Select]
# 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:

Code: [Select]
18h 2.1K 1dMX7a-0001rT-I2 <> *** frozen ***
         root@somehost.com

The command to delete a message in Exim is:

Code: [Select]
# exim -Mrm <message-id>
So, if we want to delete the message in the example above we type in:

Code: [Select]
# 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:

Code: [Select]
# 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:

Code: [Select]
# 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.
===========================================================================