You need to specify the Content-Transfer-Encoding for the MIME part with the attachment. I don't know if uuencode is a standard one. Base64 is though.
You also need to send the closing boundary marker.
Your redirection into cat is wrong.
(cat << ! From: $FROM To: $TO Subject: $SUBJECT Date: $(date +"%a, %b %e %Y %T %z") Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="$boundary" This email has attached the file --$boundary Content-Type: text/plain; charset=ISO-8859-1 Please see the attachmed file. --$boundary Content-Transfer-Encoding: base64 Content-Type: $MIME;name="$ATTACH1" Content-Disposition: attachment;filename="$ATTACH1" $(base64 "$ATTACH1") --$boundary-- ! ) | sendmail -v "$TO"