This tool has been a life-saver on our hosting servers many times. If your mail queues fill up with spam – perhaps incoming, or perhaps after your server has been hacked (timthumb - that caught a lot of people), then spam can be deleted from the outgoing queue.
For example, to remove all mail from the outgoing queue with the word “c@sino” in the subject, use this command:
Perhaps delete all mail that is stuck in the queue from user “firstname.lastname@example.org”:
Remember that last one is a regular expression, so escape any special characters.
Showing the state of the queues:
Then listing what is in those queues:
qmhandle -l | more
The qmhandle.pl script can be found here, but may well be already installed on your server, especially if you use Plesk to manage your server: