6

I've spend the last hour trying to figure out how to delete all messages from a certain mail address from the exim mail queue, after the queue was full of spam emails.

3 Answers 3

5

Delete all messages that are from [email protected]. You can add -v to the exim command in order to get more verbose output.

exiqgrep -i -f [email protected] | xargs exim -Mrm

You can do it a slightly different way where you generate a bounce message for each item. This emphasizes to the end user how much harm their compromised mailbox has been causing:

exiqgrep -i -f [email protected] | xargs exim -Mg
5
  • I found about this right here: techinterplay.com/remove-mails-exim-queue-sender.html, problem is my CentOS server doesn't have the exiqgrep program.. Thanks for the solution though!
    – Tim Baas
    Commented Feb 1, 2014 at 23:41
  • The exiqgrep script is a standard part of exim that is included with the tarball. Use 'yum search */exiqgrep' to see if it is provided by any packages on your system that either are not installed or if it is not in your path. Install it if it is available.
    – Todd Lyons
    Commented Feb 3, 2014 at 13:25
  • Does that work without xargs after the pipe?
    – Saxtus
    Commented Feb 19, 2019 at 12:35
  • 1
    This doesn't work: "exim: no message ids given after -Mrm option"
    – ygoe
    Commented Jun 10, 2020 at 20:21
  • 2
    These work for me: exiqgrep -i -f [email protected] | xargs exim -Mrm and exiqgrep -i -f [email protected] | xargs exim -Mg Commented Jun 19, 2020 at 7:55
6

Use this line to delete all messages:

exim -bp | grep [email protected] | sed -r 's/(.{10})(.{16}).*/\2/' | xargs exim -Mrm

It does the following:

exim -bp

Lists the exim mail queue

grep [email protected]

Selects only the lines with a certain mail address

sed -r 's/(.{10})(.{16}).*/\2/'

Selects the ID of the e-mail

xargs exim -Mrm

Deletes the message from the queue

I'm sure it can be optimized, please tell if so and how!

2
  • 1
    Instead of sed ... I normaly use awk '{print $3}' - prints the third column with the IDs. It's a tiny bit shorter.
    – vstm
    Commented Nov 25, 2014 at 20:47
  • Alternatively, you can use exiqgrep to get the same effect without the sed or awk.
    – liamvictor
    Commented Sep 8, 2015 at 11:53
3

The other way to clear exim queue is by print the third fields which in this case will be the email email address. Any result that matches the grep email address will be deleted by exim -Mrm command.

exim -bp | grep [email protected] | awk {'print $3'} | xargs exim -Mrm

In case if you would like to clear the frozen email, you can replace [email protected] with 'frozen'

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .