Sendmail cmd for html body and attachment not working

Hi,
I am having trouble in sending a mail with html body and attachment (csv file). We don't have uuencode or mutt (not allowed to install as well)

The below code is perfectly working for sending the html body alone:

export MAILTO=abc@xyz.com
        export CONTENT="/home/abc/list.html"
        (
        echo "Subject: $SUBJECT"
        echo "MIME-Version: 1.0"
        echo "Content-Type: text/html"
        echo "To: abc@xyz.com"
        #echo "Content-Disposition: inline"
        cat $CONTENT
        ) |  /usr/sbin/sendmail -t -i $MAILTO

The below code is perfectly working for sending the attachment alone:
( echo "to: abc@xyz.com"
  echo "from: abc@xyz.com" 
  echo "subject: sending file"
  echo "mime-version: 1.0"
  echo "content-type: multipart/related; boundary=xxxRANDOMSTRINGxxx"
  echo
  echo "--xxxRANDOMSTRINGxxx"
  echo "content-type: text/plain"
  echo
  echo "Attached is the audit info"
  echo
  echo "--xxxRANDOMSTRINGxxx"
  echo "content-type: text/html; name=newlist.txt"
  echo "content-transfer-encoding: base64"
  openssl base64 < /home/abc/list.csv ) | /usr/sbin/sendmail -t -i $MAILTO

Could some one help me how to combine it together, I tried multiple option but nothing is working. I need to trigger single email with the attachment and html body, please help me on this.

Thanks.

---------- Post updated at 08:28 PM ---------- Previous update was at 07:40 PM ----------

simple mail command is sending body with attachment but its not sending the body as html (instead it send it as plain text)

cat newlist.html | mail -s "new test" -a list.txt abc@xyz.com

Any idea how to send html body with attachment..?

Have you tried to add the content in the body?

( echo "to: abc@xyz.com"
echo "from: abc@xyz.com"
echo "subject: sending file"
echo "mime-version: 1.0"
echo "content-type: multipart/related; boundary=xxxRANDOMSTRINGxxx"
echo
echo "--xxxRANDOMSTRINGxxx"
echo "content-type: text/html"
echo
cat $CONTENT
echo "--xxxRANDOMSTRINGxxx"
echo "content-type: text/html; name=newlist.txt"
echo "content-transfer-encoding: base64"
openssl base64 < /home/abc/list.csv ) | /usr/sbin/sendmail -t -i $MAILTO

How about this:

to="abc@xyz.com"
from="testing@xyz.com"
boundary=$(uuidgen -t)
content="/home/abc/list.html"
now=$(date +"%a, %d %b %Y %T %z")

sendmail -t <<EOF!
From: ${from}
To: ${to}
Date: ${now}
Subject: Sending file
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="${boundary}"

--${boundary}
Content-type: text/html; charset=utf-8
Content-Disposition: inline

$(cat $content)
--${boundary}
content-type: text/html
content-transfer-encoding: base64
content-disposition: attachment; filename="newlist.txt"

$(openssl base64 < /home/abc/list.csv)
--${boundary}--
EOF!