Implementing a Spillover Host Concept on RedHat
by Kevin A. McGrail <kmcgrail@pccc.com>



From the MIMEDefang list posted by David F. Skoll:

I use a "spillover host concept" on my main machine.  If you look in
the Sendmail "contrib" directory, there's a very useful tool called
"qtool.pl" for moving messages from one queue directory to another.

Once an hour from cron, I run "/bin/move-old-mail-messages.sh"

and move-old-mail-messages.sh looks like this:

#!/bin/sh
#
# Move messages with more than 10 retransmission attempts to slow queue
SLOWQUEUE=/var/spool/slow-mqueue
QUEUE=/var/spool/mqueue
qtool.pl -e '$msg{num_delivery_attempts} >= 10' $SLOWQUEUE $QUEUE

So any messages that have been tried at least ten times in the regular
queue get moved to the slow queue.  The last piece of the puzzle is
that I have another queue runner for the slow queue, running once
every eight hours.

Bottom line:  If a message doesn't make it out of the regular queue
within the first 5 hours, it gets shunted out to the slow queue that
runs 1/16th as often as the regular queue.



Here's how I implemented this on a RedHat system:

#COPY THE SCRIPT AND MANPAGE TO THE PROPER PLACES
cd /usr/src/sendmail-8.12.9/contrib
cp qtool.8 /usr/share/man/man8

#I CHOSE LOCAL/SBIN FOR THE FILE WHICH I HAVE IN MY DEFAULT PATH AND USE FOR ADMIN INSTALLED STUFF
cp qtool.pl /usr/local/sbin

#MAKE SURE IT IS EXECUTABLE
chmod +x /usr/local/sbin/qtool.pl

#MAKE THE SLOW QUEUE DIR
mkdir /var/spool/slow-mqueue
chmod 755 /var/spool/slow-mqueue
chown root.mail /var/spool/slow-mqueue

#DOWNLOAD THE move-old-mail-message.sh AND PUT IN HOURLY CRON DIR
mv /tmp/move-old-mail-messages.sh /etc/cron.hourly/move-old-mail-messages.sh
chmod +x /etc/cron.hourly/move-old-mail-messages.sh

#MODIFY THE INIT SCRIPT FOR SENDMAIL
#First, I decided on the amount of time to delay the queue retransmissions and I decided on every 8 hours.
#
#I edited the sendmail sysconfig file to add a configuration variable called SLOWQUEUE

vi /etc/sysconfig/sendmail
add a line that says
SLOWQUEUE=8h

#EDIT THE SENDMAIL INIT SCRIPT TO START ANOTHER QUEUE RUNNER
#The script I use is called sendmail-slowqueueinit.  It has issues with stopping that I still haven't r
#esolved but it works in general.
mv /etc/rc.d/init.d/sendmail /etc/rc.d/init.d/sendmail.bak
cp /tmp/sendmail-slowqueueinit /etc/rc.d/init.d/sendmail
chmod +x /etc/rc.d/init.d/sendmail




#NOTES:
I used qtool to look for mail to specific domains that can be moved to a slower queue.  
I never figured out how to use the -e for searching the entire recipient array so I 
had to search the first entry.  For example:

  /usr/local/sbin/qtool.pl -e '$msg{recipient}->[0] =~ /\@domain.com/i' $SLOWQUEUE $QUEUE

I can add a few lines searching for 1,2,3,4, etc. but it's not the most efficient way.  
Anyone know a better way, email me at  kmcgrail@pccc.com.

A: Thanks to Eddie to sending me the answer:

/usr/local/sbin/qtool.pl -e 'map { return 1 if $_ =~ /hotmail/ } @{$msg{recipient}}' /usr/spool/qm/ /usr/spool/mqueue/
