Script to Remove Over Quota Message from Zimbra Queue

Sometimes we have a bunch of over quota message filling up Zimbra queue, with detail as below :

197CF170F9 59761 Wed Oct 24 09:49:48   email-palsu@vivianchow.id
(host alt1.gmail-smtp-in.l.google.com[74.125.195.27] said: 452-4.2.2 The email account that you tried to reach is over quota. Please direct 452-4.2.2 the recipient to 452 4.2.2 https://support.google.com/mail/?p=OverQuotaTemp m3-v6si2776998pld.435 – gsmtp (in reply to RCPT TO command))
email-palsu@gmail.com

The email message will be automatically removed from the queue after a while, depending on our queue lifetime setting on the server. If we want to automatically remove on the selected time interval, we can then set up crontab to run the following script :

del-over-quota.sh

#!/bin/sh

clear

/opt/zimbra/postfix/sbin/postqueue -p | grep -A 1 "over quota" | grep @ | sort | uniq > /tmp/over-quota.txt

USERS=`cat /tmp/over-quota.txt`

echo "Looping for all users"
for ACCOUNT in $USERS; do

#Remove over quota queue
echo "Account over quota : $ACCOUNT"
pfdel $ACCOUNT
echo ""
done
echo "All over quota queue has been removed successfully"

The above script is run together with pfdel script, so don’t forget to download and save pfdel script as well.

Leave a Reply