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=’https://raghunathgurjar.wordpress.com/contact-us/&#8217; target=’_blank’ title=’Raghunath’>https://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″;

 

 

Advertisements

Sr. Software Engineer

Posted in PHP

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: