Quick way to remove all emails from the mail queue – Exim command line option

We have already discussed a lot of topics regarding the Exim mail transfer agent (MTA). Here I am listing some commandline options to remove all emails from your server mail queue. We know the Exim command to remove emails from mail queue, “exim -Mrm” then followed by the mail ID. In some strange situations, huge amount of emails in the queue will cause high load on the server. In some cases, we need to find out the root cause for this huge emails in queue, it may be due to the result of Spamming on server.

Removing single mail from queue:

exim -Mrm MESSAGE-ID

How to remove all emails from the Exim mail queue?

Yes, that’s what we are discussing. We can do this in different ways. The important things are, we required the email ID and the command “exim -Mrm” to remove email from the mail queue.

Method I: Using ‘exim -bp‘

exim -bp|grep "<"|awk {'print $3'}|xargs exim -Mrm

In this method, the command ‘exim -bp’ is used to find-out the message ID from the Exim mail queue and then remove corresponding email from the mail queue by using the command ‘exim -Mrm’ as argument.

Method II: Using ‘exiqgrep‘

exiqgrep -i|xargs exim -Mrm

The exiqgrep command with ‘-i’ switch list the message ID from mail queue, then remove the mail by using the mail ID.

Linux Server Administrator. I'm dealing with Linux servers since 2012. I started this blog to share and discuss my ideas with the world. Check My Profile!! in uPwork (oDesk) and let me know if you need any assistance. Thanks!!

This is an old post but I will share a fast way of deleting all e-mails with you.
This is another way but normally you shouldn’t use it.
Only if there are thousands of e-mails (Showing the queue takes longer than some seconds).