Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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
share|improve this question
add comment

1 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
share|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 at 10:29
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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