How to re-create Qmail queue

Qmail has 500 00 messages in queue and I installed qmHandle to help sort out the spam in the queue. This process has taken a long time and alternative scripts like qmail-remove also take time. I want to move the Qmail queue to a backup (queue.BAK)and recreate a new queue so that mails can flow so long as clients cannot send or receive emails via the server at the moment. I am running Plesk 10.4 on Ubuntu 8.04 LTS.

1) Is it possible to move the queue and recreate a new queue?

2) Please outline what I have to do to achieve this.

I followed the advice below and am adding more information here. My new qmail queue has 75 messages and all are unprocessed.I am able to send using the smtp service of the server but am not getting emails. I do not see an error in the log file but trying to download the emails gives the message that there are no new messages even when I send test messages to the email address hosted on the server.

root@alpha1:/var/qmail/queue# root@alpha:/var/qmail/queue.BAK# ls -la total 4692

drwxr-x--- 12 qmailq qmail 4096 2012-05-30 14:55 .

drwxr-xr-x 13 root root 4096 2013-03-16 14:58 ..

drwx------ 2 qmails root 90112 2013-03-13 14:37 bounce

drwx------ 25 qmails qmail 4096 2012-03-06 06:30 info

drwx------ 25 qmailq qmail 4096 2012-03-06 06:30 intd

drwx------ 25 qmails qmail 4096 2012-03-06 06:30 local

drwxr-xr-x 2 qmailq qmail 4096 2012-03-06 06:30 lock

drwxr-x--- 25 qmailq qmail 4096 2012-03-06 06:30 mess

drwx------ 2 qmailq qmail 4096 2013-03-16 14:51 pid

drwx------ 25 qmails qmail 4096 2012-03-06 06:30 remote

drwxr-x--- 25 qmailq qmail 4096 2012-03-06 06:30 todo

drwxr-xr-x 2 root root 4657152 2013-03-15 15:32 yanked

root@alpha1:/var/qmail/queue# ls -la total 48

drwxr-x--- 12 qmailq qmail 4096 2013-03-16 16:41 .

drwxr-xr-x 13 root root 4096 2013-03-16 14:58 ..

drwx------ 25 qmails root 4096 2013-03-16 16:39 bounce

drwx------ 25 qmails qmail 4096 2013-03-16 16:40 info

drwx------ 25 qmailq qmail 4096 2013-03-16 16:40 intd

drwx------ 25 qmails qmail 4096 2013-03-16 16:40 local

drwxr-xr-x 25 qmailq qmail 4096 2013-03-16 16:40 lock

drwxr-x--- 25 qmailq qmail 4096 2013-03-16 16:39 mess

drwx------ 25 qmailq qmail 4096 2013-03-17 10:40 pid

drwx------ 25 qmails qmail 4096 2013-03-16 16:40 remote

drwxr-x--- 25 qmailq qmail 4096 2013-03-16 16:40 todo

drwxr-xr-x 25 root root 4096 2013-03-16 16:41 yanked


Solution 1:

1) Yes, it is.

2) First, be aware that this does risk corrupting the existing queue and you may lose some real emails. If this is not acceptable, do not follow the steps below!

Check ownership and permissions of /var/qmail/queue

mv /var/qmail/queue /var/qmail/queue.BAK
mkdir /var/qmail/queue

Restore the permissions you checked above; I don't offhand remember them and don't have a qmail server handy where I can check.

cd /var/qmail/queue
mkdir mess

for i in `seq 0 22`; do
mkdir -p mess/$i
done

cp -r mess info
cp -r mess intd
cp -r mess local
cp -r mess remote
cp -r mess todo

chmod -R 750 mess todo
chown -R qmailq:qmail mess todo

chmod -R 700 info intd local remote
chown -R qmailq:qmail intd
chown -R qmails:qmail info local remote

This gives you a new and empty queue.

There is also a tool called queue-repair, but I've never tested it so I can't vouch for it.