Search code examples
bashshellmailx

HTML formatted email using bash shell script


This is my below script which is working fine as it send only plain text email.

So My question is- How can I modify my below script to send this as an HTML formatted email? I want to show the text color of this expression (echo "100*$TEST2/$TEST1" | bc -l) as RED in an email and that can be done only in HTML formatted emails. So that is the reason I was thinking to send an email in HTML formatted way. Any suggestions will be of great help.

#!/bin/bash

TEN_DAYS="3793274 230667"

TEST1=`echo $TEN_DAYS | awk '{print $1}'`
echo $TEST1

TEST2=`echo $TEN_DAYS | awk '{print $2}'`
echo $TEST2

mailx -s "Report" -r [email protected] [email protected] <<EOF

Error  Percentage: `(echo "100*$TEST2/$TEST1" | bc -l)`

EOF

Solution

  • Here are some ways of sending html type emails with mailx

    http://www.unix.com/unix-advanced-expert-users/37480-display-html-text-body-using-unix-mailx.html