Use of java mail to send email from UNIX

Can someone help me to understand how to configure java mail on unix or what is syntex for that to put in script so email can be sent.

earlier i was using ' send mail ' to send email and not SMPT is stopped in unix machine and they asked us to use java mail.
Before I was using this

FROM="servername"
(
 echo "From: $FROM"
 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="'${ATTACH_NAME1}'"'
 echo "Content-Transfer-Encoding: uuencode"
 echo 'Content-Disposition: attachment; filename="'${ATTACH_NAME1}'"'
 echo
 uuencode $ATTACH1 $ATTACH1
 echo
 echo '---q1w2e3r4t5--'
) | /usr/sbin/sendmail $MAILTO $CC