I'd like to send a html file from a host using mailx but instead of interpreting it as html it would send it out as text (html codes). Is there a way to send it as html?

(cat <<EOCAT
Subject: TEST email
MIME-Version: 1.0
Content-Type: text/html
Content-Disposition: inline
) | mailx -r localhost@host.com myemail@website.com

You need to make it a multipart/mixed message, boundaries and all.

( cat <<EOCAT
MIME-Version: 1.0
From: $from
To: $to
Cc: $cc
Subject: TEST email w/ HTML
Content-Type: multipart/mixed; boundary=NextPart_0123456789
Content-Transfer-Encoding: 7bit
Content-Type: text/html
cat header.html
cat html_message_body.html
cat footer.html ) | mailx -r localhost@host.com myemail@website.com
| improve this answer | |
  • 2
    (and make sure that the file you contain really is 7bit encoded! - or use cat -v) – symcbean Oct 5 '11 at 11:56
  • tried. doesnt work on me. :( – afbr1201 Oct 7 '11 at 1:20
  • 2
    What OS are you using? If mailx isn't working, you could try piping to sendmail -t instead. – Tim Kennedy Oct 7 '11 at 4:53
  • mailx didn't work for me on OSX, but sendmail did. Thank you! – maksimov Feb 13 '14 at 10:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.