Mail sending by Shell with attachments

(
echo "to: ${MAIL_TO}"
echo "from: ${MAIL_FROM}"
echo "subject: ${SUBJECT}"
echo "mime-version: 1.0"
echo "content-type: multipart/mixed; boundary=\"==Multipart_Boundary_x${RANDOM_NUM}\""
echo
echo "--==Multipart_Boundary_x${RANDOM_NUM}"
echo "content-type: text/plain"
echo
echo "Content detials is here..........."
echo
echo "--==Multipart_Boundary_x${RANDOM_NUM}"
echo "content-type: application/octet-stream; name=threads_dump_${DUMP_TIME}.dmp"
echo "content-transfer-encoding: base64"
echo
openssl base64 -in "${ATTACHMENT_FILE_PATH}"
echo
) | /usr/sbin/sendmail -t -i

 

RANDOM_NUM=`date|md5sum|awk '{print $1}'`