3

Managed to get my hands on this:

#!/bin/bash

######### Edit here ##########

_mail_user=someone@bob.com # Set this to your email id to receive alerts on mail queue
_limit=100 # Set the limit here

##############################

clear;
_result="/tmp/eximqueue.txt"
_queue="`exim -bpc`"

if [ "$_queue" -ge "$_limit" ]; then
echo "Current queue is: $_queue" > $_result
echo "Summary of Mail queue" >> $_result
echo "`exim -bp | exiqsumm`" >> $_result
mail -s "Number of mails on `hostname` : $_queue" $_mail_user < $_result
cat $_result
fi

rm -f $_result

Works like a charm. Now I just have one question for someone slightly more advanced than me. Assuming the queue has exploded with spam, above message will just be in the back of the queue - so we would want to force it to be sent before anything else essentially. From my understanding, we can use the following to force delivery of one message:

/usr/sbin/exim  -M  email-id

Anyone here know how I could extract the email-id from the scripts mail function and then run the above command with it? Something along the lines of:

_message_id = "'exiqgrep -f root@hostname'"
/usr/sbin/exim  -M  "$_message_id"
1

Try

exiqgrep -f 'root@hostname' -i | xargs exim -M

You can also look at more powerful tool exipick.

  • I think that will do the trick, thanks - doesnt work fast enough on a small queue though because it insta sends :P – SupaMonkey Oct 8 '15 at 15:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.