Listing 5. Tracking Incoming and Outgoing Mail
#!/bin/sh
ST=/etc/sendmail.st
MS=/usr/sbin/mailstats
MSO=/tmp/mailstats.txt
if [ -s $ST -a -f $MS ]; then
echo "General Mail Statistics" > $MSO
echo "" >> $MSO
echo "local = Mail local to fileserver (linuxserver)" >> $MSO
echo "smtp = Internet mail" >> $MSO
echo "relay = Mail from/to Sun system (mrpserver)" >> $MSO
echo "" >> $MSO
$MS >> $MSO
cp /dev/null $ST
fi
echo "" >> $MSO
echo "Mail Filter/Forwarding Statistics (from internet)" >> $MSO
echo "" >> $MSO
/usr/bin/mailstat -l /home/thriftycompany/mail/from >> $MSO
chown thriftycompany /home/thriftycompany/mail/from
cat $MSO | mail -s "Daily Email Summary" myboss stew
rm $MSO
exit 0
Copyright © 1994 - 2018 Linux Journal. All rights reserved.