How to delete emails from qmail queue on H-Sphere

First check the status of your queue:

[root@mail1 root]# /var/qmail/bin/qmail-qstat
messages in queue: 6751
messages in queue but not yet preprocessed: 56

After you find and stop the spammer, you now have a bunch of email on your QMail queue. Here’s how to remove it

take a “user@domain.com” that happens in emails from the spammer (usually the sender) and run this command:

grep -R user@domain.com /var/qmail/queue/mess/* | awk -F”:” ‘{print “rm -f ” $1}’ | sh

make sure the quotes and single quotes are straight, not round upon copy/paste

That will delete the emails that contain that user@domain.com

but it would leave behind various indexes and later on your users would start receiving bouncebacks for emails they’ve never sent!

BETTER USE:
qmHandle/qmhandle-1.3.2/qmHandle -Fuser@domain.com

this removes not only messages, but all the mentioning of those messages from everywhere. (sasa4uk)