Bash Application – Simpler Exim Queue Management
Ever get stuck trying to remember the exim/exiqgrep/xargs commands at that one critical moment when you need to stop 800,000 spam mail getting delivered to Hotmail accounts? Me too.. So I made this to help. My other monitoring & alert scripts should have told you by now that you have a spam outbreak, so you’ll know which sending host its coming from. Fire this application up on that host to quickly and effectively manage the items in the mail queue.
#!/bin/bash
########################
# Exim Tool #
# v0.2 #
# Dave Byrne #
########################
printf "n########################n# VooServers Exim Tool #n########################nn"
printf "Select an option:nn1. Remove messages from queue by address/domainn2. Remove ALL messages from queuen3. Print detailed queue listingn4. Print quick queue summaryn5. Show simple mail queue item countn6. Print Exim's current activityn7. Test how Exim will route to an addressn8. Display headers, body or logs via Message IDnnEnter 1-8: "
read menuchoice
printf "n-----------nYou chose $menuchoicen-----------n"
case $menuchoice in
1)
printf "n1. By sending address/domainn2. By Receiving address/domainnnEnter 1-2:"
read case1opt
case $case1opt in
1)
echo "Enter full sending address or .*@domain.tld to remove from queue:"
read rmargss
exiqgrep -i -f $rmargss | xargs exim -Mrm
exit 1
;;
2)
echo "Enter full receiving address or .*@domain.tld to remove from queue:"
read rmargsr
exiqgrep -i -r $rmargsr | xargs exim -Mrm
exit 1
esac
;;
2)
echo "Are you sure? Y/N"
read conf1
if [ "$conf1" = "y" ]; then
exim -bp | exiqgrep -i | xargs exim -Mrm
printf "nEntire Mail Queue Destroyed"
fi
;;
3)
exim -bp
;;
4)
exim -bp | exiqsumm
;;
5)
count=`exim -bpc`
printf "nThere are $count mails in the exim queuenn"
;;
6)
printf "n"
exiwhat
printf "n"
;;
7)
printf "n"
echo "Enter full address to show route: "
read routeaddr
printf "n"
exim -bt $routeaddr
printf "n"
;;
8)
printf "n1. Headersn2. Bodyn3. LogsnnEnter 1-3: "
read msgopt1
case $msgopt1 in
1)
printf "Enter Message ID: "
read msgid1
exim -Mvh $msgid1
exim -Mvh $msgid1 > /var/tmp/$msgid1-header
printf "nnMessage Header also saved to file: /var/tmp/$msgid1-headernn"
;;
2)
printf "Enter Message ID: "
read msgid1
exim -Mvb $msgid1
exim -Mvb $msgid1 > /var/tmp/$msgid1-body
printf "nnMessage Body also saved to file: /var/tmp/$msgid1-bodynn"
;;
2)
printf "Enter Message ID: "
read msgid1
exim -Mvl $msgid1
exim -Mvl $msgid1 > /var/tmp/$msgid1-log
printf "nnMessage Log also saved to file: /var/tmp/$msgid1-lognn"
esac
;;
*)
printf "nnInvalid option. Try again...nn"
sleep 2
./eximtool
esac
exit 1
Current features include:
-Remove multiple messages from queue by full address/partial domain
-Remove ALL messages from queue (Careful now..)
-Print a detailed queue listing
-Print a quick queue summary
-Show a simple mail queue item count
-Print Exim’s current activity
-Test how Exim will route to a given address
-Display message headers, body or logs via Message ID and save these to a file