I want to send an HTML report that is piped from another command, eg:
mycommandthatprintshtml | mail email@example.com . When I do this currently, it prints all the html tags. Is there a way I can set the required headers to make it display in HTML formatted?
In addition to the email body, you also need to print the email headers:
echo "From: firstname.lastname@example.org\r\nDate: $(date)\r\nSubject: subject\r\nMIME-Version: 1.0\r\nContent-Type: text/html; charset=utf-8\r\n\r\n$(mycommandthatprintshtml)" mail email@example.com
Note that From, Date, Subject are mandatory. MIME-Version and Content-Type are there to help the recipient understand how the email is formatted.