0

Is there a way to send html file into a mail body using mail or mailx command in Linux. I googled around and did not find anything that's working though there are many threads. on of the thread i see Mailx send html message but nothing works.

What i used are below commands but not working as expected.

$ mail -s "$(echo -e "This is Subject\nContent-Type: text/html")"  kulfi@tap.com <  OneView_Sheet.html

$ mailx -s "$(echo -e "This is Subject\nContent-Type: text/html")"  kulfi@tap.com <  OneView_Sheet.html

The above command instead sending the html source content as follows ...

<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>OV_NAME</th>
      <th>Composer_Firmware</th>
      <th>SAS_20_Firmware_Version</th>
      <th>SAS12_Firmware_Version</th>
      <th>VC_Firmware_Version</th>
    </tr>
  </thead>
  <tbody>

Desired example as on the Body:

enter image description here

user2023
  • 452
  • 5
  • 22

1 Answers1

1

Trying with your dummy HTML table did worked with mutt. Below command can help you to get your email notifications sorted.

mutt -e "set content_type=text/html" -e "set from=sender@tap.com" -s "This is Subject" kulfi@tap.com < OneView_Sheet.html

Another common mechanism which can be preferred in case of mail & mailx failures is sendmail -t

echo To: kulfi@tap.com >mailheader.txt
echo This is Subject >>mailheader.txt
echo Content-Type: text/html >>mailheader.txt
cat OneView_Sheet.html >> mailheader.txt
cat mailheader.txt| sendmail -t

Since both mutt and sendmail are supported most of the standard flavours which are in general use, you may not need to add any additional libraries / tools.

Saiprasad Bane
  • 477
  • 4
  • 9
  • Thanks @Saiprasad Bane, this is another Good approach but i can not test it as i dont have it installed due to org reasons. but +1 for this, i have postfix with mailx and mail available. – user2023 Apr 04 '20 at 13:10