November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  

Categories

November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  

How to clear the Qmail Queue

Clear & Clean Qmail Queue Completely, Safely & Fast!

This script should not remove anything it should not remove, and it should clear all e-mail from your qmail queue safely so you can start sending mail normally again. (This is for qmail only and not a solution for any other mail programs.) You’re going to need ssh access and an ssh program like putty or putty portable.

Let’s get busy with the Qmail Clear script:

Log into your server through ssh
type this:
su –
type this:
wget http://www.howtohacks.com/scripts/qmailclear.sh
type this:
sh qmailclear.sh or sh ./qmailclear.sh
done.

You can download it and view it yourself, but just as a quick summary so you know what it’s doing, the Qmail Clear script looks like this:

echo Cleaning Queue
mv /var/qmail/queue/lock /root/
cd /var/qmail/queue; find . -type f -exec rm -f ‘{}’ \;
mv /root/lock /var/qmail/queue/
echo Queue is now Clean

If this didn’t do the trick and you’re receiving oversized file truncating errors (or “Argument list too long”) then you should use this more intense script. It will take longer but it will get the job done.

Let’s get busy with the Qmail Clean script :

Log into your server through ssh
type this:
su –
type this:
wget http://www.howtohacks.com/scripts/qmailclean.sh
type this:
sh qmailclean.sh or sh ./qmailclean.sh
done.

DO NOT restart any process. DO NOT reboot the server. DO NOT do anything until the script says it is done. If you restart a process, etc, it will break qmail and that’s no fun. Just run the script until it’s complete.

You can download the script and view all of the code yourself, but here’s a quick summary of the main lines of code so you know what’s taking place when running the Qmail Clean script:

echo “Stopping Qmail”
/etc/init.d/qmail stop
echo “Clearing the Mail Queue”
cd /var/qmail/queue/info
rm -rf blah blah blah
echo “Info folder clean, clearing mess folder”
cd /var/qmail/queue/mess
rm -rf blah blah blah
echo “Mess folder clean, clearing remote folder”
cd /var/qmail/queue/remote
rm -rf blah blah blah
echo “Remote folder clean, clearing intd folder”
cd /var/qmail/queue/intd
rm -rf blah blah blah
echo “Intd folder clean, clearing local folder”
cd /var/qmail/queue/local
rm -rf blah blah blah
echo “Local folder clean, clearing todo folder”
cd /var/qmail/queue/todo
rm -rf blah blah blah
echo “Mail queue cleaned”
echo “Restarting Qmail Now”
/etc/init.d/qmail start
echo “Qmail Started!”
echo “Done!”

If you’re interested in reading more about Qmail I recommend this book Qmail book and also these links:
A reference for qmail users – qmail.org
A qmail tutorial site – Life With Qmail

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>