Send email with html template using php - Mostlikers

16 February, 2015

Send email with html template using php

Today i want to explain about how to send email with html template using php. Normally we use php mailer function for sending email with some text also. But here i have design one html template along to send with mail script. Follow below code and have look at live demo.

Email template in php

Live demo            Download


<form action="email.php" method="post">
      <input type="text" required name="firstname" />
      <input type="email" required name="email" />
      <input type="submit" name="send" value="Submit your Request">


Extract($_POST) - Extracting Post Variables From.
file_get_contents - Html design form to get the function.
$mail - PHP mailer value along email template.
    $to="$email"; //change to ur mail address
    $strSubject="Mostlikers | Email template | $firstname";
    $message =  file_get_contents('template.php');              
    $headers = 'MIME-Version: 1.0'."\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1'."\r\n";
    $headers .= "From:"; 
    $mail_sent=mail($to, $strSubject, $message, $headers);  
        echo "<script>alert('Thank you. we will get back to you');
        echo "<script>alert('Sorry.Request not send');

HTML Email Template (template.php)

This one sample html design. you can create own html code design code. We have all ready design good design please download and use that template.
<table width="100%" cellspacing="0" cellpadding="0">
    <tr><td bgcolor="#005387"> Name : Your name </td></tr>
    <tr><td bgcolor="#005387"> Email : </td></tr>
Try it your self

No comments:

Post a Comment