해당 계정을 통해서 스팸 메일 발송이 자주 일어난다.
이렇게 되면 큐가 1000개는 기본으로 넘어가게 되어 정상적인 메일도
같이 안나게 된다.
정상적인 메일서버면 큐개수가 많아야 20~30개이므로
큐가 100개를 넘어가면 경고 메일을 보내도록 하였다.
아래 스크립트는 큐메일 용도이다.
#!/bin/sh
# Send an email when there are more then 1000 messages in the mail queue
# This is counted by the amount of lines in the qmail-qread output, so it's an indication...
show=$1
qread="/var/qmail/bin/qmail-qread"
qreadIDs=`/var/qmail/bin/qmail-qread | awk '{print $6}' | sed 's/#//' | grep -v '^$' | uniq`
len=`$qread | wc -l`
SUBJECT="WARNING: There are $len messages in the mail queue!----Country Check Version"
EMAIL="your@mail.com"
EMAILMESSAGE="/tmp/emailmessage.txt"
echo "" > $EMAILMESSAGE
chmod 777 $EMAILMESSAGE
if [ $len -gt 100 ]; then
for id in $qreadIDs
do
case "$id" in
"0.0.0.0"|"127.0.0.1"|"8.8.8.8")
continue;;
*)
#find /var/qmail/queue/mess/ -name 1449183 | xargs cat | grep mysolution-remoteip | awk '{print $2}' | xargs geoiplookup
queueFile=`find /var/qmail/queue/mess/ -name $id`
IP=`cat $queueFile | grep mysolution-remoteip | awk '{print $2}'`
# FROM=`cat $queueFile | grep From:`
# Subject=`cat $queueFile | grep Subject:`
countryChk=`geoiplookup $IP`
receiveChk=`cat $queueFile | grep Received:`
echo "Queue ID : $id --------------" >> $EMAILMESSAGE
echo "$IP : $countryChk" >> $EMAILMESSAGE
echo $FROM >> $EMAILMESSAGE
echo $Subject >> $EMAILMESSAGE
echo "$receiveChk" >> $EMAILMESSAGE
echo "-----------------------------" >> $EMAILMESSAGE
echo "" >> $EMAILMESSAGE
if [ 1 -eq $# ]; then
if [ $show = "show" ]; then
cat $EMAILMESSAGE
fi
fi
esac
done
MESSAGE=$(cat $EMAILMESSAGE)
# send an email using /bin/mail
#mail -s "$SUBJECT" "$EMAIL" < $EMAILMESSAGE
printf "To: ${EMAIL}\nSubject: ${SUBJECT}\n\n $MESSAGE" | /var/qmail/bin/qmail-inject
rm -rf $EMAILMESSAGE
fi