user1411837
user1411837

Reputation: 1564

PHP - read HTML input from a form

I have a form that will dynamically send emailers . This form takes the email id of the recipient ,the subject and the body content.

I am using PHPMailer class to go about this. When it comes to plain text ,the emailers work just fine. But I want to add a functionality where the users can paste html into the body part so that the emailer can parse/read them and send the html'ized version of the emails.

I tried this , but it didn't work as the the entire HTML was mailed as text.

$email_msg = htmlentities($_POST['mail_msg'], ENT_QUOTES, "UTF-8");

Any advice would be helpful .

Thanks in advance.

Upvotes: 2

Views: 76

Answers (2)

Grant
Grant

Reputation: 2441

Did you set the PHPMailer default to HTML:

$mail->IsHTML(true); 

Upvotes: 5

Loïc
Loïc

Reputation: 11943

Modify your mail headers :

$header  = "MIME-Version: 1.0\r\n";
$header .= "Content-type: text/html; charset: utf8\r\n";

Upvotes: 0

Related Questions