How to remove all messages from Exim mail queue via SSH

Sometimes your server may send large amount of outgoing spam (due to compromised email account or scripts) and you may require to clean all emails from Exim mail queue. Following are the few commands that will help you to remove all emails from Exim mail queue using SSH:

To print a list of the messages in the queue:

exim -bp

To remove particular message from the queue:

exim -Mrm {message-id}

To remove all messages from the queue:

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

OR

exim -bp | exiqgrep -i | xargs exim -Mrm

Leave a Reply