Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've tried emailing a normal web page using something like:

mail -s "Test Email" < webpage.htm

However, the recipient sees the raw HTML tags in the email and none of my careful formatting. Am using RedHat Linux.

share|improve this question
up vote 9 down vote accepted

You need to tell the MUA that the content contains HTML. Traditionally this is done using MIME. Try adding the following header lines to your message:

Mime-Version: 1.0
Content-Type: text/html

You may need to add a Content-Transfer-Encoding header as well. The Wikipedia page on MIME has more details, including links to relevant RFCs.

Update: This worked fine when piped into sendmail -t:

Subject: MIME Test
Mime-Version: 1.0
Content-Type: text/html

This is a test.
share|improve this answer
If I have content type application/xhtml+xml it comes as an attachment. Do You think it can be fixed? – Adobe Mar 10 '13 at 21:12
Another question: if I have inline images in html file -- how do I keep them with this method (sendmail -t)? – Adobe Mar 10 '13 at 21:19
As to inline images: I found a solution -- but gmail won't load the images (yahoo do). – Adobe Mar 11 '13 at 10:20

Solucion a envio html

mail -a 'MIME-Version: 1.0' -a 'Content-Type: text/html; charset=iso-8859-1' -a 'X-AUTOR: Ing. Gareca' -s 'MTA STATUS: mail queue'  -- -f  < /tmp/eximrep.html
share|improve this answer

it is not possible with mail afaik. But here is a short how-to with sendmail.

share|improve this answer

Sure it's possible with mail:

mail -a 'Content-type: text/html; charset="us-ascii"' < /file.html
share|improve this answer

Email messages, like web pages, have their content type specified in the headers. 'mail' seems to predate this and doesn't send any, and so all MUAs fall back to displaying the message as text/plain.

If you want to specify all headers manually, call sendmail and pass everything to it.

<subjective> But remember that while HTML emails are disliked by some people (including me), receiving HTML emails without an alternate text/plain part is really annoying. So, unless you're absolutely sure the recipient can see HTML messages fine, it would be better to send a multipart message with a plain-text part as an alternative. </subjective>

share|improve this answer
SMTP (STD 11/RFC 823, 1982) does in fact predate MIME (RFC 2045, 1996) and all of its HTML-enabled goodness. It was formed from buffalo hides at the dawn of the Internet. – Gerald Combs Jan 15 '10 at 19:40
Gerald: I meant the mailx MUA (which for some reason I feel is even older), not email itself. – grawity Jan 15 '10 at 20:01
According to the OS X mail(1) page, "A mail command appeared in Version 1 AT&T UNIX." Ubuntu says it was Version 3 AT&T UNIX. Either way it appears to have shown up around 1971 or 1973. – Gerald Combs Jan 15 '10 at 21:56

uuencode webpage.html webpage.html | mail -s "subject" email@address

share|improve this answer

Your Answer


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.