How send html with mail in PHP

Just copy this code and paste it in your page.
<?php
$subject=”testing purpose only”;
$recipient=”your mail here”;
$email_from =”From mail here”;
$headers =”From: $email_from \r\nMIME-Version: 1.0\r\nContent-type:text/html;charset=iso-8859-1″;
// Registration Mail
$msg=”<table width=’607′ border=’0′ align=’center’ cellpadding=’0′ cellspacing=’0′ style=’width:607px; border:1px solid #aaaaaa; padding:5px; height:auto;’>
<tr>
<td><table width=’596′ border=’0′ align=’center’ cellpadding=’0′ cellspacing=’0′>
<tr>
<td style=’padding:12px; font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#303030; line-height:20px;’><strong>Dear user,</strong><br />
Just enjoy your mail<br/>
<br>
Kind Regards, <br />
<strong>Raghunath Gurjar</strong> <br />
<a href=’http://raghunathgurjar.wordpress.com/contact-us/’ target=’_blank’ title=’Raghunath’>http://raghunathgurjar.wordpress.com/contact-us/</a><br />
<p>You can also contect me for any more query on <a href=”mailto:raghunath.0087@gmail.com”>raghunath.0087@gmail.com</a></p>
</td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>”;
// Send mail
mail($recipient,$subject,$msg,$headers);
?>
 
 
Note:Some time Google mail is not supported this format. so please in that case you can use below given stepes for change content type in your header :

  1. $headers =”From: $email_from \r\nMIME-Version: 1.0\r\nContent-type:text/html;charset=utf-8″;  
  2.  OR
  3. $headers =”From: $email_from \nMIME-Version: 1.0\nContent-type:text/html;charset=utf-8″;

 
 

Leave a Reply

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