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

Remove emails from queue.

We have already discussed a lot of topics regarding the Exim mail transfer agent (MTA). Here I am listing some command-line 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.

Method III:

exim -bp | awk '/^ *[0-9]+[mhd]/{print "exim -Mrm " $3}' | bash

That’s it!!

 

Related Links:

Command to find out the spam mailing script’s location
Remove all frozen emails from mail queue
Remove emails from mail queue for a specific Sender/Receiver
Check spamming on server having EXIM

 

Analysing mail log details – Exim log file flags a detailed view

You will get more details about the spamming and the commands to analyse it. Here I’m explaining about the exim mail log. Exim mail log file is “/var/log/exim_mainlog

From the email queue, we can analyse the log details of an email by using the command “exim -Mvl Message-ID”

,

Post navigation

Arunlal Ashok

Linux Systems Architect at Endurance International Group. I know her (Linux) since many years. Linux lover. Like to play on Linux console. I started this blog to share and discuss Linux thoughts.

Always happy for an open discussion! Write to arun (@) crybit (dot) com. Check about me for more details. About this blog and our strong members, check The team CryBit.com

9 thoughts on “Quick way to remove all emails from the mail queue – Exim command line option

  1. Method III: exim -bp | awk ‘/^ *[0-9]+[mhd]/{print “exim -Mrm ” $3}’ | bash

    IS SLOW!

    Method II doesn’t appear to do anything

    Method I: FASTEST!

  2. Hey there,

    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).

    Delete them in the file system.

    cd /var/spool/exim4/
    (Change the directory to exim4 folder)

    mv input/ input_
    (Move the input folder to input_)

    mv msglog msglog_
    (Move the msglog to msglog_)

    rm -rf input_ msglog_ &
    (Delete input_ and msglog_ / The & sends the remove process to the background so it won’t block your shell)

    Sorry for my bad English.

Leave a Reply

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