help in sending email in html format

i am trying to send email in html format using web form .for this purpose i added tinymce in my web form but when i send email i received email in broken html please help. my code is

[code]<?php
$send = $_POST[‘send’];
if($send){
$email = $_POST[‘email’];

            $emailfile = file_get_contents("mailing.txt");
            $emaillist = explode("\n", $emailfile);
            
            foreach ($emaillist as $value)
            {
            mail($value, $_POST['subject'], $_POST['message'], "From: $email");
            }
            
            echo "<b>Email sent!</b><br />";

}
?>

Subject:
From:
Message:
 
[/code]

First thing what you need to add is correct content-type to email headers. This is a forth argument of PHP mail() function. In your case content-type must be set to text/html:
[php]mail($value, $_POST[‘subject’], $_POST[‘message’], “From: $email\nContent-type: text/html;”);[/php]

Then, depending on what email client you (or other recipients of this email message) are using, you need to use best practices of HTML email coding for that email client. For example, for some of email clients you will need to use inline css styles instead of defining css styles in html head or body, some would not display background images in your html (Gmail), etc.

Sponsor our Newsletter | Privacy Policy | Terms of Service