checking the status of sendmail

Hi All,

I like to check the status of sendmail and take the appropriate action based on success / failure etc.

I have gone through one of the thread where a suggestion is made to use RC for return code

Following is the code:

#!/usr/bin/bash
export MAILTO="xxx@yyy.zzz"
export LOGFILE="1.log"
export SUBJECT="Report"
export BODY="/devhome/tmanda/1.html"
export ATTACH1="/devhome/tmanda/coa.pdf"
export ATTACH1_NAME=${ATTACH1##*/}
echo "ATTACH1_NAME=$ATTACH1_NAME"
export ATTACH2="/devhome/tmanda/gatd.txt"
export ATTACH2_NAME=${ATTACH2##*/}
echo "ATTACH2_NAME=$ATTACH2_NAME"
(
 echo "To: $MAILTO"
 echo "Subject: $SUBJECT"
 echo "MIME-Version: 1.0"
 echo 'Content-Type: multipart/mixed; boundary="-q1w2e3r4t5"'
 echo
 echo '---q1w2e3r4t5'
 echo "Content-Type: text/html"
 echo "Content-Disposition: inline"
 echo
 cat $BODY
 echo
 echo '---q1w2e3r4t5'
 echo 'Content-Type: application; name="'${ATTACH1_NAME}'"'
 echo "Content-Transfer-Encoding: uuencode"
 echo 'Content-Disposition: attachment; filename="'${ATTACH1_NAME}'"'
 echo
 uuencode $ATTACH1 $ATTACH1
 echo
 echo '---q1w2e3r4t5'
 echo 'Content-Type: application; name="'${ATTACH2_NAME}'"'
 echo "Content-Transfer-Encoding: uuencode"
 echo 'Content-Disposition: attachment; filename="'${ATTACH2_NAME}'"'
 echo
 uuencode $ATTACH2 $ATTACH2
 echo
 echo '---q1w2e3r4t5--'
) | sendmail $MAILTO
RC=$?
echo "sendmail rc=$RC" 

But, this is always returning 0 irrespective of To address is valid or invalid.
Is there a proper way of checking whether the mail is successfully sent or any error and then take an appropriate action.