3

Friends,

os : linux

script : ksh

logfile: repot.html

mail : mailx

I'm trying to send HTML file as attachment via ksh script -> mailx command.

I can easily send text file as attachment but as soon as I change file to html, mailx doesn't recognize file and send email with html tags. I tried using uuencode, cat mailhtml etc.. various syntax which I got from internet but somehow nothing works.

I tried attaching html file manually to email and test whether my email client is having problem, but no attachment did sent/receive without any error.

I'm using below syntax, could somebody look and see what I'm missing? $report is a variable which stores html file name.

"
(cat mailhtml; uuencode report.html) | mailx -s "Monthly Report" manager@gmail.com < $report
"

Below works sending normal text logfile

mailx -s "Monthly Report" manager@gmail.com < $report

Thank you for looking into this and hopefully this can be achieved via mailx.

homer
  • 423
  • 2
  • 11
  • 24
  • You'll find some techniques that you can adapt in this question: http://stackoverflow.com/q/17359/7552. You'll need to send a multi-part message with a part that is content-type: text/html – glenn jackman Mar 04 '14 at 01:57
  • @glennjackman thank you very much, that helped a lot. But still I'm not able to send html in attachment using "uuencode" error: uuencode: not found. – homer Mar 04 '14 at 19:18
  • You don't need uuencode. Start with [this](http://stackoverflow.com/a/4887607/7552), remove the "filename" stuff, and change the content-type for the "$body" section to "text/html" – glenn jackman Mar 04 '14 at 19:51
  • @glennjackman Link was useful and cleared many doubts, saved in my bookmark list. with my poblem I was able to use "mutt" on different server and file attachment was easy and single liner. Thanks – homer Mar 06 '14 at 15:17
  • does it HAVE to be with mailx? or can it also be with MailTo? – Gal Appelbaum Nov 06 '15 at 19:57

0 Answers0