We help IT Professionals succeed at work.

How to delete specific messages from sendmail queue FROM a certain email address?

Chris Kenward
Chris Kenward used Ask the Experts™
I have suddenly had one of my customer Email servers go balistic (possibly compromised) and they use our sendmail server as a relay. We have over 100,000 rubbish messages from them (all from the SAME Email address) in our mail queue. We have been relaying this nonsense for long enough to have been blacklisted on some of the biggies. I urgently need to run something to delete these messages from the queue.

I have always used Webmin for this task but it seems this time there are too many messages in the queue and Webmin simply gasps and dies, not completing the search.

I hope someone can help - we know the FROM address we want to delete. Is there some script I can run on this queue which will delete specific messages with a specific FROM address in the queue? We currently have our server down and are receiving loads of support calls but I cannot put it back up again until we have deleted the messages currently in the queue.

I have disabled reaying from the customer and blocked their IP in the firewall. Now all I need do is get rid of the pesky messages.

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Normally queues can be access using the command 'mailq' and should be under /var/spool/mqueue

Check these links if you want a start as they provide very good information

There are some scripts there,


Try using

 sendmail -qS -v sender@address.com 

Open in new window

That will remove all mail from sender@address.com
Chris KenwardIT Tech Support


Hey there, rabbid_dog

Would this actually delete all messages from that address which were in the queue? Would sendmail have to be running to achieve this or could we stop the sendmail service and then issue the command on its own?

Also, if it was all messages addressed TO: a specific address what would the command be then?