Last active
December 29, 2015 02:58
-
-
Save Aricg/7603876 to your computer and use it in GitHub Desktop.
If the deferred queue has more than 2000 messages and some of those deferred messages have more than 10 recipients this script emails the email address and and number of deferred messages that have over ten recipients to $1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| detect_spammers () { | |
| numq=$(su - zimbra -c "mailq" | wc -l) | |
| if (( $numq > 2000 )); | |
| then | |
| echo "number of messages deferred: $numq" | |
| echo "# of messages per user" | |
| sendmail "$@" \ | |
| < <(echo -en "spammers detected on host:"; hostname; echo "| # deferred | email@address |"; su - zimbra -c "mailq" | tail -n +2 | grep -v '^ *(' \ | |
| | awk 'BEGIN { RS=""; }{ if (NF > 10 ) print $7 }' \ | |
| | tr -d '*!' | sort | uniq -c) | |
| fi | |
| } | |
| detect_spammers support@enovance.com |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment