Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

linux mail adding content type headers not working

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: [email protected]
To: [email protected]
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" [email protected]

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" "[email protected]" < $tempfile

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

like image 573
ɹɐqʞɐ zoɹǝɟ Avatar asked Mar 20 '23 05:03

ɹɐqʞɐ zoɹǝɟ


1 Answers

Try

echo "<b>HTML Message goes here</b>" | mail -s "$(echo -e "This is the subject\nContent-Type: text/html")" [email protected]

How to send HTML email using linux command line

like image 59
deimus Avatar answered Mar 27 '23 13:03

deimus