How to remove all messages from exim mail queue from a certain user/email

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

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!