Zimbra mailq notification email [Script-2]
Step: 01
Login as root and create below mentioned script:
vi /root/mailq.sh
Login as root and create below mentioned script:
vi /root/mailq.sh
#!/bin/bash
mailq_count="$(/opt/zimbra/common/sbin/mailq | /usr/bin/tail -n1 | /usr/bin/gawk '{print $5}')"
mailq_status="$(su - zimbra -c mailq|grep ^[A-F0-9]|cut -c 42-80|sort |uniq -c|sort -n|tail)"
DOM=domain.com
ZCS=mail.$DOM
FROM=adminx@$DOM
TO=imsilsa26112@gmail.com
# If variable is empty, then the queue is empty -> set it to zero
if [ -z "$mailq_count" ]; then
mailq_count=0
fi
##################################################################################
#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#
##################################################################################
if [ "$mailq_count" -gt 200 ]; then
/opt/zimbra/common/sbin/sendmail -i $FROM $TO <<MAIL_END
Subject: Mail queue || mail.$DOM
FROM: $FROM
To: $TO
Mail queue count on mail.$DOM ${mailq_count}
$ZCS
***********************
$mailq_status
MAIL_END
fi
Step: 02
#chmod +x /root/mailq.sh
Step: 03
#crontab -e
*/2 * * * * /root/mailq.sh
#chmod +x /root/mailq.sh
Step: 03
#crontab -e
*/2 * * * * /root/mailq.sh
Comments
Post a Comment