Skip to content

Instantly share code, notes, and snippets.

@Aricg
Last active December 29, 2015 01:09
Show Gist options
  • Select an option

  • Save Aricg/7591268 to your computer and use it in GitHub Desktop.

Select an option

Save Aricg/7591268 to your computer and use it in GitHub Desktop.
deal with deferred/spammy messages in the postfix queue.
#Removes any deferred messages from the postfix queue if the message has more that 50 recipients. run as root.
su - zimbra -c "mailq" | tail -n +2 | grep -v '^ *(' | awk 'BEGIN { RS=""; }{ if (NF > 50 ) print $1 }' | tr -d '*!' | /opt/zimbra/postfix/sbin/postsuper -d -
#Could be used to detect users sending spam and sent via an email to the administrators.
mailq | tail -n +2 | grep -v '^ *(' | awk 'BEGIN { RS=""; }{ if (NF > 10 ) print $7 }' | tr -d '*!' | sort | uniq -c
example output:
577 foo@bar.com
#Lock accounts that have more than 100 diffrent deffered messages with at least ten recipients in each
for x in $(awk '{if ($1 > 100) print $2}' < <(mailq | tail -n +2 | grep -v '^ *(' | awk 'BEGIN { RS=""; }{ if (NF > 10 ) print $7 }' | tr -d '*!' | sort | uniq )); do \
zmprov ma $x zimbraAccountStatus locked
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment