HTML Designed email looks pretty good, when compared to ordinary text email (without applying style). Most of the emails from a concern are html designed, some of the email are Daily newsletter, verification mail, notification mail. while send html email using php, our brand will be popular with our theme colored email.
This will work only
- When the code is uploaded in server (or)
- SMTP configuration in localhost
HTML Designed email
Important in HTML Designed Email
This two header coding only make html code into html element. Without using this coding in header, html code will appears as html code (not as design) like the below image.
[code type=php]
$headers .= “MIME-Version: 1.0\r\n”;
$headers .= “Content-Type: text/html; charset=ISO-8859-1\r\n”;
[/code]
Note: When you use image in html code, don’t use local folder path. Upload the image in server and give full path.
i.e., dont use like this /images/logo.png
Use like this http://www.freezecoders.com/logo.png
PHP Code
[code type=php]
<?php
$email=”mail@example.com”;
$subject = “Freeze Coders HTML Email”;
$headers = “From: you@example.com \r\n”;
$headers .= “Reply-To: you@example.com \r\n”;
$headers .= “MIME-Version: 1.0\r\n”;
$headers .= “Content-Type: text/html; charset=ISO-8859-1\r\n”;
$message = ‘<html><body>’;
$message.='<div style=”margin: 0 auto; width: 550px; background-color: #7096DA; padding: 15px; font-weight: bold; font-size: 33px;”>’;
$message.=’Freeze Coders’;
$message.='</div>’;
$message.='<div style=”font-family: Arial; margin: 0 auto; width: 542px; border: 10px solid #E2E2E2; padding: 10px;”>Tutorial: How to Send HTML Designed Email<br/>’;
$message.='</div>’;
$message.='</body></html>’;
mail($email,$subject,$message,$headers);
?>
?>
[/code]