Not able to drop single mail transfer for different conditions.

. /apps01/wls01/Oracle/Middleware/user_projects/domains/soadomain/bin/setDomainEnv.sh > /dev/null
cd /apps01/wls01/Oracle/Middleware/wlserver_10.3/common/bin
java weblogic.WLST ServerStatus.py > a.log
TEST=`cat a.log | grep WARN | wc -l`
if [ $TEST != 0 ]; then
        `grep "WARN" a.log > 1.txt`
     mail -s "$TEST ServersWarningMode`hostname`"  xyz.mail.com < 1.txt
fi
A=soa_server1
B=bam_server1
c=AdminServer
TEST1=`cat a.log | grep soa_server1 | wc -l`
TEST2=`cat a.log | grep bam_server1 | wc -l`
TEST3=`cat a.log | grep AdminServer | wc -l`
if [ $TEST1 = 0 ]; then
        `grep "soa_server1" a.log > 1.txt`
mail -s "$A is down, please check `hostname`" abc.mail.com
fi
if [ $TEST2 = 0 ]; then
        `grep "bam_server1" a.log > 2.txt`
mail -s "$B is down, please check `hostname`" abc.mail.com
fi
if [ $TEST3 = 0 ]; then
        `grep "AdminServer" a.log > 3.txt`
mail -s "$C is down, please check `hostname`" abc.mail.com
fi
 

Here i need the condition like if Two servers are down then only one mail is triggered not 2 mails. Whatever the no of servers are down, it should trigger only one mail.

> mail_body
for server in soa_server1 nbam_server1 AdminServer
do
        if ! grep "$server" a.log > /dev/null
        then
                printf "$server is down, please check $( hostname )\n"
        fi
done > mail_body

[[ -s mail_body ]] && mail -s "Servers Down" abc.mail.com < mail_body