0

I want to store my matrix's data in a html file and send a email in outlook ,my code looks as follows:

  printf "<!DOCTYPE html>"
  printf "<html>"
  printf "<head>"
  printf "<style>"

  printf "</style>"
  printf "</head>"
  printf "<body>"

  printf "<table>"
    printf "<tr>"
     printf "<th>Total</th>"
      printf "<th>StillFail</th>"
      printf "<th>Pass</th>"
      printf "<th>ScriptError</th>"
      printf "<th>APIName</th>"
    printf "</tr>"
    printf "<tr>"
  echo
       for ((j=1;j<=num_rows;j++)) do
        printf "<tr>"
       for ((i=1;i<=num_columns;i++)) do
              printf "<td>"
              printf "${matrix[$j,$i]}"
              printf  "</td>"
        printf "</tr>"
        done
   echo
   done
  printf "</tr>"
  printf "</table>"

  printf "</body>"
  printf "</html>"
  #mailx -a 'Content-Type: html' -s "my subject" [email protected] < output.html
  mailx -s "TESTING MAIL"</home/test/example/output.html  "[email protected]"

I want my output as a well aligned table. Can someone help me on this? TIA

2 Answers2

0

You need to append content-type in header it can be done with -a flag in mailx

comment your last line and try this

mailx -a 'Content-Type: text/html' -s "Test MAIL" [email protected]</home/test/example/output.html

Edit :

As per the OP End error : content-type:texthtml no such file or directory

To install mailutils in mac

Press Command+Space and type Terminal and press enter/return key.
Run in Terminal app:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null
and press enter/return key. Wait for the command to finish.
Run:
brew install mailutils

reference : http://macappstore.org/mailutils/

Arun pandian M
  • 862
  • 10
  • 17
0

Maybe you can use this for a base:

    (
echo "To: ADRESSES"
echo "Subject: SUBJECT"
echo "Content-Type: text/html"
echo
echo "HTML code"
) | /usr/sbin/sendmail -F "NameOfSender" -t
NetMonk
  • 55
  • 6