20Dec/10Off
Sending HTML email from a bash script
I had a situation where I needed to set up a cron job to send email reports based on the contents of a dynamically generated web page. I tried piping the output of wget and curl to the mail command, but each time the recipient would receive raw HTML instead of an HTML formatted email.
This was far more challenging than one would initially guess.
After a lot of googling and trial and error I came up with the following:
(cat <<EOCAT
Subject: ##Subject##
From: from@address.edu
MIME-Version: 1.0
Content-Type: text/html
Content-Disposition: inline
EOCAT
curl https://www.edu/url/?view=123) | /usr/sbin/sendmail email@address
Posting it here may help someone else, or help me later.