Manage the Qmail mail queue

Mattias Geniar, Wednesday, June 4, 2008 - last modified: Sunday, November 16, 2014

Ever used qmail? Ever had a mail stuck in the queue that just wouldn't send?

Then you might want to give qmHandle a try. It's a small tool you'll need to download (~16KB), and it'll save you quite some time.

Running "qmHandle -l" lists the current queue. Nothing special about that, running "/var/qmail/bin/qmail-qstat" will do the same. Then how do you send the mails stuck in the queue? The logs won't tell you the reason why they're still in there. Running "qmHandle -a" will force the mails in queue to be sent. If for some reason this still fails, the mails will remain in queue.

Now try deleting a mail (or a series of mails) from the queue, based on -- let's say -- the subject. Now it gets harder if you want to use qmail's built-in tools.

qmHandle simplifies this. Running the command "qmHandle -S'Viagra Penis Enlargments' " will delete all messages from the queue, where the subject contains the string contained in single quotes (note: the single quotes have to be entered directly after -S, there can be no space in between).

qmHandle has a lot more functionality, which you can discover by typing "qmHandle". It'll give you an output as follows:

Available parameters:

-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
-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/delete multiple message i.e. -d123 -v456 -d567

Just explore qmHandle a bit, you'll find it quite nice and invaluable when working with a qmail-enabled system.

Hi! My name is Mattias Geniar. I'm a Support Manager at Nucleus Hosting in Belgium, a general web geek, public speaker and podcaster. If you're interested in keeping up with me, have a look at my podcast and weekly newsletter below. For more updates, follow me on Twitter as @mattiasgeniar.

I respect your privacy and you won't get spam. Ever.
Just a weekly newsletter about Linux and open source.

SysCast podcast

In the SysCast podcast I talk about Linux & open source projects, interview sysadmins or developers and discuss web-related technologies. A show by and for geeks!

cron.weekly newsletter

A weekly newsletter - delivered every Sunday - for Linux sysadmins and open source users. It helps keeps you informed about open source projects, Linux guides & tutorials and the latest news.

Share this post

Did you like this post? Will you help me share it on social media? Thanks!


Leave a Reply

Your email address will not be published. Required fields are marked *

Inbound links