How to send html email with PHP – solved

If you are a developer and using PHP for development then in some projects you need to create email functions according to client requirement. You can send simple emails by using default mail function of PHP. Here is a piece of code which allows you to send HTML mail with proper usage of extra headers. This will give more flexibility so you can attach files format it in HTML and many more.

	$to   = "";
	$from = '';
	$headers = "From: " . strip_tags($from) . "\r\n";
	$headers .= "Reply-To: ". strip_tags($from) . "\r\n";
	$headers .= "CC:\r\n";
	$headers .= "MIME-Version: 1.0\r\n";
	$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
	$message = '<html><body>';
	$message .= '<table width="100%"; rules="all" style="border:1px solid #3A5896;" cellpadding="10">';
	$message .= "<tr><td colspan=2>Hello \$Name,<br /><br />Expand the message part according to your design layout</td></tr>";
	$message .= "</table>";
	$message .= "</body></html>";
	mail($to, $subject, $message, $headers);
Tags: ,

Related posts:

HTML5 page structure

HTML5 offers more powerful structure comparing to older versions of Html. There are many new …

Partner with Us

We are providing an exclusive partnership offer to individuals and companies who are interested in setting up their own web design & development company. For more information about how to partner with us, please contact us