Sending HTML mail using PHP

<?php
// multiple recipients
$emailto  = 'emailto@example.com';
// note: For Multi emailto user comm

// subject
$subject = 'Email Subject For the mail';

// message
$message = '
<html>
<head>
  <title>Title of th email</title>
</head>
<body>
  <p>Folling is the Details</p>
  <table>
    <tr>
      <th>Some Name 1</th><th>Some Name 2</th>
    </tr>
    <tr>
      <td>Some Value 1</td><td>Some Value 1</td>
    </tr>
    <tr>
      <td>Some Value 1</td><td>Some Value 1</td>
    </tr>
    <tr>
      <td>Some Value 1</td><td>Some Value 1</td>
    </tr>
  </table>
</body>
</html>
';

// 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";

// Additional headers if required
$headers .= 'To: name 1 <name1@example.com> ' . "\r\n";
$headers .= 'From: Name of the sender <sender@example.com>' . "\r\n";
$headers .= 'Cc: cctothisemail@cctothisemail.com' . "\r\n";
$headers .= 'Bcc: bcctothisemail@cctothisemail.com' . "\r\n";
// Additional headers if required


// Mail it
mail($to, $subject, $message, $headers);
// Mail it

?>

Comments

Popular posts from this blog

Page Unload Show Notification to user

Function Oriented File Upload PHP

Upload File Using PHP - Example For Image