Cpanel email queue notification script.

Create a file called mailqueue.sh.


 vim /root/mailqueue.sh


 Add the following code.



#!/bin/bash


EMAIL=”youraddress@mail.com”


MQUEUE=`find /var/spool/exim/input -name ‘*-H’ | wc -l | sed -e “s/ //g”`


if [ $MQUEUE -gt 200 ]; then
echo “Mail queue at `hostname` has $MQUEUE messages!!!” | mail -s “CRITICAL ALERT: Mail queue” $EMAIL
fi

  
 Save the file and schedule a cronjob to execute the file on every minute.


     # crontab -e

and set the following cronjob


       * * *  *  *  /bin/sh /root/mailqueue.sh

 

Cpanel email queue notification script.

Leave a Reply

Your email address will not be published. Required fields are marked *

Fork me on GitHub