Deleting email from the exim queue is unfortunately not that simple. If you have a massive spammer in your system, you can clear the email originating from them with the command below.

exim -bpru | tr '\n' + | sed -e "s/++/=/g" | tr -d + | tr = '\n' | grep "spammer@email.com" | awk {'print $3'} | xargs exim -Mrm

Simple replace the spammer@email.com address with the potential spammer.
Don’t forget that this command uses the whole queue list to process. Sometimes if you have hundreds of thousands of email from this spammer in queue, it will get hard to process them all for the system. So instead of using the whole queue list, we can break it down to pieces with the head command.

The command below will break it down to pieces of 5000, so if you have more than 5000, you should run this command several times.

exim -bpru | head -n 5000 | tr '\n' + | sed -e "s/++/=/g" | tr -d + | tr = '\n' | grep "spammer@email.com" | awk {'print $3'} | xargs exim -Mrm

To delete all mails from the queue, simply use this command.

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

About The Author