#!/bin/bash # Hopefully I can get this to work, it should be able to helps with troubleshooting email issues MAILLOGFILE="/var/log/exim/main.log" LOCALDOMAINFILE="localdomains" EMAILADDR=$1 SEARCHTERM=$EMAILADDR LOCAL=false isDomainLocal() { grep $1 $LOCALDOMAINFILE > /dev/null if [[ $? == 0 ]] then TMPVAL=`echo $EMAILADDR | cut -d '@' -f 1` SEARCHTERM=$TMPVAL echo "$TMPVAL" fi } DOMAIN=`echo $EMAILADDR | cut -d '@' -f 2` isDomainLocal $DOMAIN echo "$SEARCHTERM" echo "---------Email Throughput for $1--------" echo "Emails Sent by: `exigrep $SEARCHTERM $MAILLOGFILE | grep "<= $SEARCHTERM" | wc -l`" echo "Emails Sent to: `exigrep $SEARCHTERM $MAILLOGFILE | grep "=> $SEARCHTERM" | wc -l`" echo "Total emails with $1: `exigrep $SEARCHTERM $MAILLOGFILE | grep -i 'completed' | wc -l`" echo "" echo "--------Email ID's for sent/received--------" echo "Sent By ID's:" echo "`exigrep $SEARCHTERM $MAILLOGFILE | grep "<= $SEARCHTERM" | awk '{print $3 " From " $6 ":" $7}' `" echo "Sent To ID's:" echo "`exigrep $SEARCHTERM $MAILLOGFILE | grep "=> $SEARCHTERM" | awk '{print $3" To " $8 ":" $9}' `" echo "" echo "-------Emails Send from Hosts-------"