How to send HTML mail in PHP
www.parnets.in
To send HTML mail in PHP, you need to use some additional headers. Below is the code to send HTML mail in PHP.
$to = “recipient@domain.com“;
$subject= “Subject of email”;
$message= “This is <h1>HTML</h1> mail.”;
$fromName = “Name of the sender”;
$fromEmail = “sender@domain.com“;
$subject= “Subject of email”;
$message= “This is <h1>HTML</h1> mail.”;
$fromName = “Name of the sender”;
$fromEmail = “sender@domain.com“;
// 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”;
$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”;
$headers .=”From: $fromName <$fromEmail>”.”\r\n”;
//Mail function
mail($to, $subject, $message, $headers);
mail($to, $subject, $message, $headers);