Bash – send html using mailx

bashemailhtmlmailx

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
EOCAT
header
cat $MSGFILE
footer
) | mailx -r localhost@host.com myemail@website.com

Best Answer

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
--NextPart_0123456789
Content-Type: text/html
EOCAT
cat header.html
cat html_message_body.html
cat footer.html ) | mailx -r localhost@host.com myemail@website.com
Related Question