Home >>Advance PHP Tutorial >Sending HTML Email

Sending HTML Email

How to Send HTML Sturucture using mail fucntion

Second Part of the this tutorial i.e how to Send HTML Email using Php Mail() Function.

<?php

//Receiever of the mail
$to="info@gmail.com";

//subject of the mail
$subject = "ProductDetails";

//message of the mail which contains some html 
$message ="
<table width='400' border='1'>
  <tr bgcolor='#CCCCCC'>
    <th>Name </th>
    <th>Email</th>
  </tr>
  <tr>
    <td>rajeev</td>
    <td>rajeev@gmail.com</td>
  </tr>
  <tr>
    <td>ravi</td>
    <td>ravi@yahoo.com</td>
  </tr>
  <tr>
    <td>rexx</td>
    <td>rexx@gmail.com</td>
  </tr>
</table>";


$headers .= "From:info@phptpoint.com";

$headers .= "Content-type: text/html; charset=iso-8859-1rn";

mail($to, $subject, $message, $headers);

echo $message;

?>

in above example , a proper tabular format is sent to receiver . To do this we have to make changes in header and add content type . Receiver will receive tabular format not the HTML code of mail.


No Sidebar ads