I've tried emailing a normal web page using something like:
mail -s "Test Email" [email protected] < webpage.htm
However, the recipient sees the raw HTML tags in the email and none of my careful formatting. Am using RedHat Linux.
Server Fault is a question and answer site for system and network administrators. It only takes a minute to sign up.
Sign up to join this communityI've tried emailing a normal web page using something like:
mail -s "Test Email" [email protected] < webpage.htm
However, the recipient sees the raw HTML tags in the email and none of my careful formatting. Am using RedHat Linux.
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
:
From: [email protected]
To: [email protected]
Subject: MIME Test
Mime-Version: 1.0
Content-Type: text/html
<html>
<body>
This is a test.
</body>
</html>
application/xhtml+xml
it comes as an attachment. Do You think it can be fixed?
sendmail -t
)?
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' [email protected] -- -f [email protected] < /tmp/eximrep.html
Sure it's possible with mail:
mail -a 'Content-type: text/html; charset="us-ascii"' [email protected] < /file.html
Content-type: text/html; charset="us-ascii": No such file or directory.
From mail --help, I get that the -a option is for passing FILE.
Mar 30, 2018 at 9:40
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 [email protected]
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>
mailx
MUA (which for some reason I feel is even older), not email itself.
Jan 15, 2010 at 20:01