Question

i am using mail command to send mails from my linux system.

The problem i am getting is the Content type of the mail is always as Content-Type: text/plain; charset=us-ascii.

I am sending the html content and it is displaying as plain text.

This is what i have tried

1)
body="From: me@example.org
To: me@gmail.com
Subject: MIME Test
Mime-Version: 1.0
Content-Type: text/html

<html>
<body>
This is a test.
</body>
</html>";

echo $body| mail -s "testing purpose" reciever@gmail.com

this didn't worked

i put this html in a file called test.html in $tempfile and tried to execute like this

2)
mail -a 'MIME-Version: 1.0' -a 'Content-Type: text/html; charset=iso-8859-1' "server details" "receiver@gmail.com" < $tempfile

But nothing has worked, please suggest me regarding this (please only using mail not sendmail/mutt).

Was it helpful?

Solution

Try

echo "<b>HTML Message goes here</b>" | mail -s "$(echo -e "This is the subject\nContent-Type: text/html")" foo@example.com

How to send HTML email using linux command line

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top