How to send HTML mail in PHP

To send HTML mail in PHP, you need to use some additional headers. Below is the code to send HTML mail in PHP.

$to = ““;
$subject= “Subject of email”;
$message= “This is <h1>HTML</h1> mail.”;
$fromName = “Name of the sender”;
$fromEmail = ““;

// To send HTML mail, the Content-type header must be set
$headersĀ  = “MIME-Version: 1.0″ . “\r\n”;
$headers .= “Content-type: text/html; charset=iso-8859-1″ . “\r\n”;

// Additional headers
$headers .=”From: $fromName <$fromEmail>”.”\r\n”;

//Mail function
mail($to, $subject, $message, $headers);


Leave a Reply

Your email address will not be published. Required fields are marked *

− six = 2

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>