Send HTML email with PHP
PHP provides programmers the mail() function to send email messages. With the addition of a few instructions you can send messages in HTML format.
<?php
// Recipient of the email
$recipient = "name@company.com";
//Subject of message
$subject = "HTML mail message from PHP!";
//HTML Message
$message = '
<html>
<body bgcolor="#dddddd" text="#888888">
<div align="center">
<table width="500" border="0" cellspacing="1" cellpadding="1" bgcolor="#ffffff">
<tr>
<td>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit,
sed diam nonummy nibh euismod tincidunt ut laoreet dolore
magna aliquam erat volutpat.
<br />
Lorem ipsum dolor sit amet, consectetuer adipiscing elit,
sed diam nonummy nibh euismod tincidunt ut laoreet dolore
magna aliquam erat volutpat.
</td>
</tr>
<tr bgcolor="#EFEFEF">
<td bgcolor="#EFEFEF" >Receive this email because it is subscribed to our newsletter</td>
</tr>
</table>
</div>
</body>
</html>
';
// We must define the Content-type header
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
if(mail($recipient, $subject, $message, $headers))
echo( 'Message sent successfully' );
else
echo( 'It was not possible to send the message' );
?>