Linux – How to get HTML file as a content to mail (shell script)

bashlinuxscriptshell

I am new to shell script, I have an HTML file which contains table data. Now I need to send this file to mail.

mail -s "test" abc.com <test.html

Currently I am getting the raw HTML code for the table in mail.

I need the table content in mail as we get in Internet Explorer.

Best Answer

Try adding -a "Content-type: text/html;" to the message like this:

mail -a "Content-type: text/html;" -s "test" abc.com <test.html

You can easily test this by running this command that echo’s simple HTML to the mail command:

echo "<html><b>Test</b></html>" | mail -a "Content-type: text/html;" -s "test" abc.com

Got this idea from this question and answer thread on Unix & Linux Stack Exchange as well as this similar thread on Stack Overflow.

Related Question