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..?