How can I send an HTML email using a shell script?
The question asked specifically on shell script and the question tag mentioning only about sendmail package. So, if someone is looking for this, here is the simple script with sendmail usage that is working for me on CentOS 8:
#!/bin/sh
TOEMAIL="youremail@server.com"
REPORT_FILE_HTML="$REPORT_FILE.html"
echo "Subject: EMAIL SUBJECT" >> "${REPORT_FILE_HTML}"
echo "MIME-Version: 1.0" >> "${REPORT_FILE_HTML}"
echo "Content-Type: text/html" >> "${REPORT_FILE_HTML}"
echo "" >> "${REPORT_FILE_HTML}"
echo "" >> "${REPORT_FILE_HTML}"
echo "Best practice to include title to view online email " >> "${REPORT_FILE_HTML}"
echo "" >> "${REPORT_FILE_HTML}"
echo "" >> "${REPORT_FILE_HTML}"
echo "Hello there, you can put email html body here
" >> "${REPORT_FILE_HTML}"
echo "" >> "${REPORT_FILE_HTML}"
echo "" >> "${REPORT_FILE_HTML}"
sendmail $TOEMAIL < $REPORT_FILE_HTML