8

How can i send the email using mailx command including the HTML code? for example:

mailx -s "Report" << EOF
Report Generated
<table width="600">
<tr><td width="30%">&nbsp;&nbsp;</td><td width="35%" style="font-size:7pt;">Definition</td></tr></table>EOF

however the mail did send, but which is not as html code..

Anybody know how to send mailx including the html inside the mail body?

sean
  • 141
  • 2
  • 2
  • 10
  • 1
    Use sendmail instead, as defined here: http://stackoverflow.com/questions/17359/how-do-i-send-a-file-as-an-email-attachment-using-linux-command-line/14213935#14213935 – Eric Leschinski Jan 16 '13 at 04:17

3 Answers3

7

I havent used mailx for sending HTML but have used sendmail. You can use the following if you can use sendmail instead of mailx

(echo -e "Subject: $SUBJECT\nMIME-Version: 1.0\nFrom: $MAIL_FROM\nTo:$MAIL_TO\nContent-Type: text/html\nContent-Disposition: inline\n\n";/bin/cat $MAIL_FILE) | /usr/sbin/sendmail -f  $MAIL_FROM $MAIL_TO

I tried this on Linux

Benjie
  • 7,701
  • 5
  • 29
  • 44
Raghuram
  • 3,937
  • 2
  • 19
  • 25
  • This is the only answer that worked for me. I guess it just can't be done with mailx. – Nic Feb 08 '13 at 17:29
0

the -a "Content-Type..." works with mailx on Ubuntu.

PrgWiz
  • 1
0

mailx allows you to specify additional headers with the -a option. So you can use something as mailx -a "Content-Type: text/html".