• Home
  • Free Stuff
  • About
  • Contact

Script to Delete the Spam Queue on Zimbra with Confirmation

October 20, 2018

On previous script, we can delete spam from queue by passing sender or recipient address on the script :
[code lang=”bash”]
pfdel email-spammer
[/code]

But what about situation where spammer filling up queue with random sender and recipient, and it tooks time to delete each message. Yes, we can use Postfix powerful binary, with postsuper -d ALL but it will remove entire message, including normal message.

Below is a modified script, to delete spam queue by confirming whether the message are legitimate or not. It will display sender and recipient so we can check each message accordingly.

[code lang=”bash”]
#!/bin/sh

#Hapus Layar
clear

/opt/zimbra/postfix/sbin/postqueue -p | grep -A 1 “$1” | grep @ | sort | uniq | cut -d “:” -f3 | cut -d ” ” -f3 > /tmp/over-quota.txt

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

echo “Looping for all users”
for ACCOUNT in $USERS; do
ACC1=`echo $ACCOUNT | awk -F@ ‘{print $1}’`;
ACC2=`echo $ACCOUNT | cut -d ‘.’ -f1`
#echo $ACC1
#echo $ACC2

/opt/zimbra/postfix/sbin/postqueue -p | grep $ACCOUNT -A 3
echo -n “Remove queue for account : $ACCOUNT [Y/N]? ”
read TANYA
if [ $TANYA == Y ] || [ $TANYA == y ]; then
pfdel $ACCOUNT
fi
echo “”
done
echo “Removal queue messages for $1 has been completed successfully”
[/code]
The script will also takes time if queue contains too many spam messages, so a better choice is to prevent spam by strengthening server anti spam and enforcing a tight security policy.

ScriptSpamZimbra
Share

Linux

Masim "Vavai" Sugianto
Traveller, Open Source Enthusiast & Book Lover. Works as Independent Worker & Self-Employer.

Comment


Mike Hammett
December 18, 2018 at 21:13
Reply

My postqueue is located at: /opt/zimbra/common/sbin/postqueue



Leave a Reply Cancel reply

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

  • Recent Posts

    • Januari 2021 Portfolio Update
    • December 2020 Portfolio Update
    • After a While
    • Life goes On : Farming
    • Pursuing FIRE in Indonesia : Are You Prepared For A Recession?
    • VirtualBox Error Kernel Driver not Installed (rc=-1908) on Zorin OS 15.2
    • ZorinOS on Intel NUC Hades Canyon Series NUC817HVK
    • Banana Farm
    • Zorin OS 15.2 Ultimate
    • Haraka and LDAP Authentication with Zimbra



© Copyright LetsBlog Theme Demo - Theme by ThemeGoods