Sending HTML Email with PHP

<?php
// multiple recipients
$to  = 'receiver@example.com' ;

// subject
$subject = 'Simple Html Email';

// message with HTML body 
$message = '<html>
             <head>
              <title>Html Email With php</title>
             </head>
           <body>
             <div>". strip_tags($_POST['name']) . "</div>
             <div>". strip_tags($_POST['email']) . "</div>
             <div>". strip_tags($_POST['message']) . "</div>
           </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
$headers .= 'To: hello <receiver@example.com>' . "\r\n";
$headers .= 'From: hello <sender@example.com>' . "\r\n";
$headers .= 'Cc: web@example.com' . "\r\n";
$headers .= 'Bcc: develope@example.com' . "\r\n";

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

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