How to clear the Qmail queue

Q My server is running Qmail and I have a lot of failure notice emails in the mail queue. How do I clear the mail queue on my mail server?

A To solve this problem you'll need a tool called QmHandle. It can easily be downloaded from http://hurricane.hinasu.net/scripts/qmHandle. This is a modified version of the tool with some extra functionality added. Using QmHandle you can then delete messages based on sender and also on recipient. Run ./qmHandle to get more information; here's a run-down of the parameters available (taken from the man page):

-a: try to send queued messages now (Qmail must be running).
-l: list message queues.
-L: list local message queue.
-R: list remote message queue.
-s: show some statistics.
-mN: display message number N.
-dN: delete message number N.
-Stext: delete all messages that have/contain text as Subject.
-Ftext: delete all messages that have/contain text as Sender.
-Ttext: delete all messages that have/contain text as Recipient
-D: delete all messages in the queue (local and remote)
-V: print program version Additional (optional) parameters:
-c: display colored output
-N: list message numbers only (to be used either with -l, -L or -R)

You can view or delete multiple message ie -d123 -v456 -d567. So to answer your question, you would need to run the QmHandle command like this:

./qmHandle -S'failure'

Follow us on Identi.ca or Twitter

Username:   Password:
Create Account | About TuxRadar