Sending HTML emails with PHP is actually alot easier than many would want you to believe.
First off, lets define the to, from and subject fields.
$to = 'joe123@hotmail.com'; //The email address you wish to send to//
$from = 'joe123@hotmail.com'; //The email address you wish the message to come from//
$subject = 'An HTML Email';
Next, define the email headers.
$headers = "From: $from\r\n"; //Defines the from address
$headers .= "Content-type: text/html\r\n"; //Sets the content type to text/html
Next, write the content of the message. Here we assign this to the variable $message.
//begin message
$message = <<<EOF
<html>
<body bgcolor="#E9F0FA">
<p>
<strong>This is an HTML Email message</strong><br />
<br />
<a href="http://www.epicarena.com/">epicarena.com</a>
</p>
<p>
You can now send HTML emails.</p>
</body>
</html>
EOF;
//end of message
Finally, send the message using the standard mail function.
//Send the email
mail($to, $subject, $message, $headers);
Simple
$to = 'joe123@hotmail.com'; //The email address you wish to send to//
$from = 'joe123@hotmail.com'; //The email address you wish the message to come from//
$subject = 'An HTML Email';
$headers = "From: $from\r\n"; //Defines the from address
$headers .= "Content-type: text/html\r\n"; //Sets the content type to text/html
//begin message
$message = <<<EOF
<html>
<body bgcolor="#E9F0FA">
<p>
<strong>This is an HTML Email message</strong><br />
<br />
<a href="http://www.epicarena.com/">epicarena.com</a>
</p>
<p>
You can now send HTML emails.</p>
</body>
</html>
EOF;
//end of message
//Send the email
mail($to, $subject, $message, $headers);
Posted by OLLIE at 23:02pm
No comments yet. Be the first to add one!