With heirloom-mailx you can change sendmail program to your hook script, replace headers there and then use sendmail.
The script I use (~/bin/sendmail-hook
):
#!/bin/bash
sed '1,/^$/{
s,^\(Content-Type: \).*$,\1text/html; charset=utf-8,g
s,^\(Content-Transfer-Encoding: \).*$,\18bit,g
}' | sendmail $@
This script changes the values in the mail header as follows:
Content-Type:
to text/html; charset=utf-8
Content-Transfer-Encoding:
to 8bit
(not sure if this is really needed).To send HTML email:
mail -Ssendmail='~/bin/sendmail-hook' \
-s "Built notification" [email protected] < /var/www/report.csv