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
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] | 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] | exim -Mg
-
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 BaasFeb 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. Feb 3, 2014 at 13:25
-
-
1
-
2These work for me:
exiqgrep -i -f [email protected] | xargs exim -Mrm
andexiqgrep -i -f [email protected] | xargs exim -Mg
Jun 19, 2020 at 7:55
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!
-
1Instead of
sed ...
I normaly useawk '{print $3}'
- prints the third column with the IDs. It's a tiny bit shorter.– vstmNov 25, 2014 at 20:47 -
Alternatively, you can use exiqgrep to get the same effect without the sed or awk. Sep 8, 2015 at 11:53
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'