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" test@example.com < output.html
  mailx -s "TESTING MAIL"</home/test/example/output.html  "test@example.com"

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

  • whats the output for this ? `mailx -a 'Content-Type: html' -s "my subject" tapariak@amazon.com < output.html` – Arun pandian M Jul 28 '17 at 06:34
  • my script name is parseScript.sh, so when I run this script I run as follows: ./parseScript.sh > output.html ,so that my output should store in output.html and then I am mailing that file using mail –  Jul 28 '17 at 06:36
  • i dont understand what your are saying anyway your mail is of content-type `text` change it to `html` are you using `mailUtils` ? – Arun pandian M Jul 28 '17 at 06:37
  • Where to change content type of mail? –  Jul 28 '17 at 06:39
  • try my answer and let me know – Arun pandian M Jul 28 '17 at 06:43
  • Possible duplicate of [Mailx send html message](https://stackoverflow.com/questions/24010230/mailx-send-html-message) – IcedAnt Jul 28 '17 at 06:46
  • I have already seen that post and that command is not working for me so I asked it again here @icedant –  Jul 28 '17 at 06:47

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" test@example.com</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