Like Us on Facebook

How to Send Mail with HTML Template using PHP

Today our topic about How to Send Mail with Email or HTMLTemplate using PHP . In this section we have already discussed how to send mail which is only some text but in this post i am going discuss how send email with HTML templates, which is also called email template. Also in download section you can download full source code of HTML template but our focus is how to send this template as mail using PHP.


 

HTML CODE
<form action="#" id="ContactForm" method="post" enctype="multipart/form-data">
        <table border="0" cellspacing="5" cellpadding="5" style="background-color:#CCCCCC; text-align:center;">
            <tr>
                 <td width="15%">Name:</td>
                 <td width="85%">
<input name="name" type="text" required></td>
             </tr>
              <tr>
                 <td>Email:</td>
                 <td>
<input name="email" type="email" required></td>
             </tr>
          
             <tr>
                 <td colspan="2">
<input name="sub" type="submit" value="Submit"></td>
             </tr>
      
         </table>

                            
   </form>

PHP CODE
<?php
error_reporting(E_ALL && ~E_NOTICE);
if ($_SERVER["REQUEST_METHOD"] == "POST") {

$name=$_REQUEST['name'];
$email=$_REQUEST['email'];

        $to=$email; //change to ur mail address
        $subject="UandBlog - Send Email Template Demo";
        $message =  file_get_contents('Your template path');  Your Template
        $headers = 'MIME-Version: 1.0'."\r\n";
        $headers .= 'Content-type: text/html; charset=iso-8859-1'."\r\n";
        $headers .= "From: noreply@uandblog.com"; 
        
        mail($to, $subject, $message, $headers);  // Mail Function

}
?>

Posted By UandBlog

UandBlog is a Global Leading source of Finance, Health, Lifestyle, Technology, Gaming and Programing and other information, it is a fastest growing blog for all , for latest post or information like us on facebook , follow on Twitter, Google+ and Pinterest.

Comments ( 0 )

    Leave a comment..

    Click to login.