# Description:
#   This script attempts to check if the James Mail Server is being 
#   'spammed' and if so it will send an email to certain people warning them
#   that their email server is an 'open relay' for spam. The script does this by
#   looking at the outgoing spool directory and seeing if there are a vast number
#   of email waiting there to be sent. If so, this script assumes that some kind 
#   of spamming is going on. This assumption may not be correct if ella associates
#   decides to send large amounts of email out. But this is extremely unlikely
#
# Notes:
#   Because the mail server itself will be crapped out if it is being spammed we 
#   cannot send the warning email through it. For this reason I am going to use a 
#   program called 'bashmail.sh' which I wrote, which is just a shell script which
#   sends an email through SMTP
#
# Dependencies
#   The 'nc' or 'netcat' program. This program is capable of sending arbitrary
#   stuff to tcp internet sockets.
#   The 'bashmail.sh' program which constructs the smtp protocol string which interacts
#   with the smtp server. Since bashmail cannot deal with authentication it can only
#   interact with SMTP servers which do not require this (eg yahoo or hotmail)
#
sAdministratorEmail="matth3wbishop@yahoo.com"

 if [ $(ls /usr/bin/james-2.1.1/apps/james/var/mail/outgoing/ | wc -l) -gt 200 ]
 then
   bashmail-better.sh $sAdministratorEmail \
     "Spam warning: The James Mail Server may be being spammed. type james.log.smtpserver on server to check" \
     matthew@ella-associates.org "Ella James Spam Warning" "mx1.mail.yahoo.com"
  
   sAdministratorEmail="nick@findesign.org"

   bashmail-better.sh $sAdministratorEmail \
     "Spam warning: The James Mail Server may be being spammed. type james.log.smtpserver on server to check" \
     nick@findesign.org "Ella James Spam Warning" "findesign.org"

 fi