How to send HTML email using PHP

This is the code to send an HTML email using PHP. You need to do all the styling on this page. No external styling work for HTML Email

  • Copy the code.
  • Replace with your content.
	$to ='[email protected]';
	$from = '[email protected]';
	$subject = 'Html Eamil Check';
	$message = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
				<html xmlns="">
				<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
				<title>Untitled Document</title>

				<div style="width:400px; height:400px; background-color:#096; color:#FFF">
				<h1>Welcome to inet shopping site</h1>
				Dear Santosh,
				We have received your Cash-On-Delivery order. We need to confirm your order by call. We will get in touch with you soon on Your order 				will be processed only after confirmation.
				For the payment, please pay Rs. 4000 cash to the courier person when he delivers the product.
				"Please call us on 8882248819 to confirm after you deposit the amount."
	$headers = "From: $from\n";
	$headers .= "MIME-Version: 1.0\n";
	$headers .= "Content-type: text/html; charset=iso-8859-1\n";
	if(mail($to, $subject, $message, $headers)){
		echo 'ok';
		echo 'error';


Santosh Devnath
PHP Developer