My blog has moved!

You should be automatically redirected. If not, visit
http://benohead.com
and update your bookmarks.

Monday, April 2, 2012

Empty qmail remote queue

A few weeks ago, we had some emails which got stuck in the remote queue of qmail. Our server kept trying to process them again but it never succeeded. After a few days I wanted to just empty the queue to stop seeing in the log files messages about failed delivery.

Unfortunately there seems to be no built-in function in qmail to empty a queue (although I'd love to be proven wrong). So I started looking for a solution how the get rid of these messages.

Since qmhandle was already installed on our server I tried using it to empty the queue. This didn't work on our server but here's how to do it (maybe it will work for you...):

Delete all messages containing a specific string in the subject:
 
#qmHandle -S"subject_substring_to_delete"

Delete all messages in both the local and remote queues:

#qmHandle -D

Since this didn't work, I started looking for other solutions.

There's a tool called Qmail-Remove. Unfortunately I wasn't able to download it and it looks like it's not really maintained anyway...

After some more searching, I finally found out that it's pretty easy to empty the queue without any tool.

You just have to stop qmail with:

/etc/init.d/qmail stop

(if it doesn't work try one of these:

/etc/rc.d/init.d/qmail stop
/etc/rc.d/qmail stop
qmailctl stop
)

Then you just need to delete all files in the subdirectories of /var/qmail/queue/remote (or another path if your queues are stored somewhere else):

find /var/qmail/queue/remote -type f -exec rm {} \;

Instead of "remote" you can enter another subdirectory of "queue" to empty another queue e.g. local.

An then start qmail again:

/etc/init.d/qmail start

That's it. Now you can check the queue status, with one of the following:

# qmHandle -s
# qmail-qstat
# qmail.qread
# qmailctl queue

They should all show that your queue is now empty !

No comments:

Post a Comment