Force Email Delivery on Exim

Hundred emails are queuing on your mail relay server, and you have to push the email to the destination mail server after it has came online. Using exim -M can helps you to delivery the email instantly.

First and foremost, find out how many email is in the queue for a specific domain


shell> exim -bp | grep [domain name]
shell> 
44m  1.7M xxxxx-000HXZ-4V 
          email@xxx.com
44m  803K xxxxx-000HZ0-0h 
          email2@xxx.com
44m   74K xxxxx-000Gzk-6M 
          email3@xxx.com

Alright, you have grepped the email which are queuing on your mail server, which delivered to your relay server on 44 minutes ago with the email id. To deliver the email to destination mail server


shell> exim -M xxxxx-000HXZ-4V
shell> exim -M xxxxx-000HZ0-0h
shell> exim -M xxxxx-000Gzk-6M

What is there are more than 50 emails? Here is a simple sample bash script showing how to deliver the email to destination email server.


EXIM=/usr/local/sbin/exim
GREP=/usr/bin/grep
AWK=/usr/bin/awk

MAILID=(`$EXIM -bp | $GREP [the-domain] | $AWK '{print $3}'`)


for item in ${MAILID[*]}
do
    echo "flush email ID $item"
    $EXIM -M $item
done

Sit back and relax, the email is being push to the destination mail server. Check your email logs to see delivery status.