Today i want explain about 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
Html
<form action="email.php" method="post">
<p>
<input type="text" required name="firstname" />
</p>
<p>
<input type="email" required name="email" />
</p>s
<p>
<input type="submit" name="send" value="Submit your Request">
</p>
</form>
Email.php
Extract($_POST) - Extracting Post Variables From.
file_get_contents - Html design form to get the function.
$mail - PHP mailer value along email template.
<?php
if(isset($_POST['send']))
{
extract($_POST);
$to="$email"; //change to ur mail address
$strSubject="Mostlikers | Email template | $firstname";
$message = file_get_contents('templete.php');
$headers = 'MIME-Version: 1.0'."\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1'."\r\n";
$headers .= "From: info@mostlikers.com";
$mail_sent=mail($to, $strSubject, $message, $headers);
if($mail_sent)
echo "<script>alert('Thank you. we will get back to you');
window.location='index.php';exit();</script>";
else
echo "<script>alert('Sorry.Request not send');
window.location='index.php';exit();</script>";
}
?>
Template.php
<html>
<body>
<table width="100%" cellspacing="0" cellpadding="0" style="max-width:600px;border-left:solid 1px #e6e6e6;border-right:solid 1px #e6e6e6">
<tbody>
<tr>
<td width="10" bgcolor="#28354d" style="width:10px;background:linear-gradient(to bottom,#28354d 0%,#28354d 89%);background-color:#28354d"> </td>
<td valign="middle" align="left" height="50" bgcolor="#28354d" style="background:linear-gradient(to bottom,#28354d 0%,#28354d 89%);background-color:#28354d;padding:0;margin:0"><a style="text-decoration:none;outline:none;color:#ffffff;font-size:13px" href="http://www.mostlikers.com" target="_blank">
<img border="0" height="30" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgLANffVSkowI7IR9QzajpvxuJinHAcJdsA9sxKAaHDSn3iG3ORIJitTTVLC-ZTxM4fwa0rm7S6FeI8EKPMBUXVcaaw2dHTlCI8e9qFrr5j1l0sBN9NU-rbTz_EvqtgLY9Ozojcv3mwcCU7/s1600/mos.png" alt="mostlikers.com" style="border:none" class="CToWUd">
</a></td>
<td valign="middle" align="right" height="50" bgcolor="#28354d" style="background:linear-gradient(to bottom,#28354d 0%,#28354d 89%);background-color:#28354d;padding:0;margin:0"><a style="text-decoration:none;outline:none;color:#ffffff;font-size:12px" href="http://mostlikers.2my4edge.com/" target="_blank">
</a></td>
<td width="10" bgcolor="#28354d" style="width:10px;background:linear-gradient(to bottom,#28354d 0%,#28354d 89%);background-color:#28354d"> </td>
</tr>
</tbody>
</table>
<table width="100%" cellspacing="0" cellpadding="0" style="max-width:600px;border-left:solid 1px #e6e6e6;border-right:solid 1px #e6e6e6">
<tbody>
<tr>
<td valign="top" align="center" width="300"><table border="0" cellspacing="0" cellpadding="0" width="100%" bgcolor="#005387">
<tbody>
<tr>
<td valign="middle" align="right" width="20%" height="35" style="border-bottom:solid 1px #003a5e;padding:0;color:#ffffff"><a style="text-decoration:none;outline:none;display:block" href="" target="_blank">
</a></td>
<td valign="middle" width="30%" align="left" height="35" style="border-bottom:solid 1px #003a5e;border-right:solid 1px #1a6592;padding:0 0 0 5px"><a style="text-decoration:none;outline:none;display:block" href="http://www.mostlikers.com/search/label/PHP?max-results=7" target="_blank">
<span style="font-size:11px;color:#99bacf;line-height:14px">PHP</span><br>
</a></td>
<td valign="middle" align="right" width="20%" height="35" style="border-bottom:solid 1px #003a5e;border-left:solid 1px #003a5e;padding:0;color:#ffffff"><a style="text-decoration:none;outline:none;display:block" href="http://www.mostlikers.com/search/label/PHP?max-results=7" target="_blank">
</a></td>
<td valign="middle" align="left" width="30%" height="35" style="border-bottom:solid 1px #003a5e;border-right:solid 1px #1a6592;padding:0 0 0 5px"><a style="text-decoration:none;outline:none;display:block" href="http://www.mostlikers.com/search/label/Web%20tricks?max-results=7" target="_blank">
<span style="font-size:11px;color:#99bacf;line-height:14px">WEB TRICKS</span>
</a></td>
</tr>
</tbody>
</table></td>
<td valign="top" align="center" width="300"><table border="0" cellspacing="0" cellpadding="0" width="100%" bgcolor="#005387">
<tbody>
<tr>
<td valign="middle" align="right" width="20%" height="35" style="border-bottom:solid 1px #003a5e;border-left:solid 1px #003a5e;padding:0;color:#ffffff"><a style="text-decoration:none;outline:none;display:block" href="http://mostlikers.2my4edge.com/" target="_blank">
</a></td>
<td valign="middle" align="left" width="30%" height="35" style="border-bottom:solid 1px #003a5e;border-right:solid 1px #1a6592;padding:0 0 0 5px"><a style="text-decoration:none;outline:none;display:block" href="http://www.mostlikers.com/search/label/Mysqli?max-results=7" target="_blank">
<span style="font-size:11px;color:#99bacf;white-space:nowrap;line-height:14px">MYSQLI</span>
</a></td>
<td valign="middle" align="right" width="20%" height="35" style="border-bottom:solid 1px #003a5e;border-left:solid 1px #003a5e;padding:0;color:#ffffff"><a style="text-decoration:none;outline:none;display:block" href="" target="_blank">
</a></td>
<td valign="middle" align="left" width="30%" height="35" style="border-bottom:solid 1px #003a5e;padding:0 0 0 5px"><a style="text-decoration:none;outline:none;display:block" href="http://mostlikers.2my4edge.com/" target="_blank">
<span style="font-size:11px;color:#99bacf;line-height:14px">DEMOS</span>
</a></td>
</tr>
</tbody>
</table></td>
</tr>
</tbody>
</table>
</body>
</html>
Email template in php
Live demo Download
Html
<form action="email.php" method="post">
<p>
<input type="text" required name="firstname" />
</p>
<p>
<input type="email" required name="email" />
</p>s
<p>
<input type="submit" name="send" value="Submit your Request">
</p>
</form>
Email.php
Extract($_POST) - Extracting Post Variables From.
file_get_contents - Html design form to get the function.
$mail - PHP mailer value along email template.
<?php
if(isset($_POST['send']))
{
extract($_POST);
$to="$email"; //change to ur mail address
$strSubject="Mostlikers | Email template | $firstname";
$message = file_get_contents('templete.php');
$headers = 'MIME-Version: 1.0'."\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1'."\r\n";
$headers .= "From: info@mostlikers.com";
$mail_sent=mail($to, $strSubject, $message, $headers);
if($mail_sent)
echo "<script>alert('Thank you. we will get back to you');
window.location='index.php';exit();</script>";
else
echo "<script>alert('Sorry.Request not send');
window.location='index.php';exit();</script>";
}
?>
Template.php
<html>
<body>
<table width="100%" cellspacing="0" cellpadding="0" style="max-width:600px;border-left:solid 1px #e6e6e6;border-right:solid 1px #e6e6e6">
<tbody>
<tr>
<td width="10" bgcolor="#28354d" style="width:10px;background:linear-gradient(to bottom,#28354d 0%,#28354d 89%);background-color:#28354d"> </td>
<td valign="middle" align="left" height="50" bgcolor="#28354d" style="background:linear-gradient(to bottom,#28354d 0%,#28354d 89%);background-color:#28354d;padding:0;margin:0"><a style="text-decoration:none;outline:none;color:#ffffff;font-size:13px" href="http://www.mostlikers.com" target="_blank">
<img border="0" height="30" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgLANffVSkowI7IR9QzajpvxuJinHAcJdsA9sxKAaHDSn3iG3ORIJitTTVLC-ZTxM4fwa0rm7S6FeI8EKPMBUXVcaaw2dHTlCI8e9qFrr5j1l0sBN9NU-rbTz_EvqtgLY9Ozojcv3mwcCU7/s1600/mos.png" alt="mostlikers.com" style="border:none" class="CToWUd">
</a></td>
<td valign="middle" align="right" height="50" bgcolor="#28354d" style="background:linear-gradient(to bottom,#28354d 0%,#28354d 89%);background-color:#28354d;padding:0;margin:0"><a style="text-decoration:none;outline:none;color:#ffffff;font-size:12px" href="http://mostlikers.2my4edge.com/" target="_blank">
</a></td>
<td width="10" bgcolor="#28354d" style="width:10px;background:linear-gradient(to bottom,#28354d 0%,#28354d 89%);background-color:#28354d"> </td>
</tr>
</tbody>
</table>
<table width="100%" cellspacing="0" cellpadding="0" style="max-width:600px;border-left:solid 1px #e6e6e6;border-right:solid 1px #e6e6e6">
<tbody>
<tr>
<td valign="top" align="center" width="300"><table border="0" cellspacing="0" cellpadding="0" width="100%" bgcolor="#005387">
<tbody>
<tr>
<td valign="middle" align="right" width="20%" height="35" style="border-bottom:solid 1px #003a5e;padding:0;color:#ffffff"><a style="text-decoration:none;outline:none;display:block" href="" target="_blank">
</a></td>
<td valign="middle" width="30%" align="left" height="35" style="border-bottom:solid 1px #003a5e;border-right:solid 1px #1a6592;padding:0 0 0 5px"><a style="text-decoration:none;outline:none;display:block" href="http://www.mostlikers.com/search/label/PHP?max-results=7" target="_blank">
<span style="font-size:11px;color:#99bacf;line-height:14px">PHP</span><br>
</a></td>
<td valign="middle" align="right" width="20%" height="35" style="border-bottom:solid 1px #003a5e;border-left:solid 1px #003a5e;padding:0;color:#ffffff"><a style="text-decoration:none;outline:none;display:block" href="http://www.mostlikers.com/search/label/PHP?max-results=7" target="_blank">
</a></td>
<td valign="middle" align="left" width="30%" height="35" style="border-bottom:solid 1px #003a5e;border-right:solid 1px #1a6592;padding:0 0 0 5px"><a style="text-decoration:none;outline:none;display:block" href="http://www.mostlikers.com/search/label/Web%20tricks?max-results=7" target="_blank">
<span style="font-size:11px;color:#99bacf;line-height:14px">WEB TRICKS</span>
</a></td>
</tr>
</tbody>
</table></td>
<td valign="top" align="center" width="300"><table border="0" cellspacing="0" cellpadding="0" width="100%" bgcolor="#005387">
<tbody>
<tr>
<td valign="middle" align="right" width="20%" height="35" style="border-bottom:solid 1px #003a5e;border-left:solid 1px #003a5e;padding:0;color:#ffffff"><a style="text-decoration:none;outline:none;display:block" href="http://mostlikers.2my4edge.com/" target="_blank">
</a></td>
<td valign="middle" align="left" width="30%" height="35" style="border-bottom:solid 1px #003a5e;border-right:solid 1px #1a6592;padding:0 0 0 5px"><a style="text-decoration:none;outline:none;display:block" href="http://www.mostlikers.com/search/label/Mysqli?max-results=7" target="_blank">
<span style="font-size:11px;color:#99bacf;white-space:nowrap;line-height:14px">MYSQLI</span>
</a></td>
<td valign="middle" align="right" width="20%" height="35" style="border-bottom:solid 1px #003a5e;border-left:solid 1px #003a5e;padding:0;color:#ffffff"><a style="text-decoration:none;outline:none;display:block" href="" target="_blank">
</a></td>
<td valign="middle" align="left" width="30%" height="35" style="border-bottom:solid 1px #003a5e;padding:0 0 0 5px"><a style="text-decoration:none;outline:none;display:block" href="http://mostlikers.2my4edge.com/" target="_blank">
<span style="font-size:11px;color:#99bacf;line-height:14px">DEMOS</span>
</a></td>
</tr>
</tbody>
</table></td>
</tr>
</tbody>
</table>
</body>
</html>
0 comments:
Post a Comment