Skip to content

Instantly share code, notes, and snippets.

@aymencis
Created June 25, 2015 18:17
Show Gist options
  • Save aymencis/2940fd785e2e2f03657b to your computer and use it in GitHub Desktop.
Save aymencis/2940fd785e2e2f03657b to your computer and use it in GitHub Desktop.
SPAM CHECK ON POSTFIX MAIL QUEUE
#!/bin/sh
NB=$(/usr/sbin/postqueue -p | wc -l)
CONTACT=email@email.com
MAIL="/tmp/mailspam"
LIMIT=600
echo START CHECKING SPAM $(date) > $MAIL
echo "" >> $MAIL
if [ $NB -gt $LIMIT ]
then
echo THERE IS $NB MAIL IN QUEUE , PLEASE TAKE A CLOSE LOOK >> $MAIL
echo "" >> $MAIL
cat $MAIL | mail -s "SPAMQUEUE REPORT" $CONTACT
else
echo $NB less than $LIMIT >> $MAIL
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment