can anyone give me php email template??, i have form ready and the fields name are as shown below:
Name:
Email:
Phone:
Subject:
Message:
pls help me i have email template design you just give me php code that shows that template in email

Recommended Answers

All 3 Replies

you just give me php code

Show your efforts and we will help if you are stuck. DO NOT ask for code.

Read our rules (which you agreed to when signing up), especially: "Do provide evidence of having done some work yourself if posting questions from school or work assignments"

**this is my Email.php file : **

<?php
if(isset($_POST['send']))

   extract($_POST); 
    $to="$email"; //change to ur mail address
    $strSubject="Mostlikers | Email | $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 .= "Bcc: karthicktech77@gmail.com\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>";
}
?>

**This is my template.php file: **

<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="http://2.bp.blogspot.com/-ACPNUKELfPo/VAi1614YnwI/AAAAAAAABMk/yUEk1GIOuNQ/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>
<table width="100%" cellspacing="0" cellpadding="0" style="max-width:600px;border-left:solid 1px #e6e6e6;border-right:solid 1px #e6e6e6">
  <tbody>
    <tr>
      <td align="left" valign="top" style="color:#2c2c2c;display:block;line-height:20px;font-weight:300;margin:0 auto;clear:both;border-bottom:2px dashed #ccc;background-color:#f9f9f9;padding:20px" bgcolor="#F9F9F9"><p style="padding:0;margin:0;font-size:16px;font-weight:bold;font-size:13px"> Hi Developer
        </p>
        <br>
        <p style="padding:0;margin:0;color:#565656;line-height:22px;font-size:13px"> Thanks for visiting our site
          <a href="http://www.mostlikers.com"> www.mostlikers.com,</a>
          This is customised Email template. i hope this tutorial is really helpful and useful to you. </p></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" style="background-color:#f9f9f9"><br>
        <table width="100%" cellspacing="0" cellpadding="0">
          <tbody>
            <tr>
              <td valign="top" align="left" style="padding:0 10px 15px 20px;margin:0;border-right:dashed 1px #b3b3b3"><a href="http://www.mostlikers.com" style="text-decoration:none;" >
                  <p style="padding:0;margin:0 0 7px 0;font-size:16px;color:#565656">TUTORIALS</p>
                  <p style="padding:0;margin:0;font-size:11px;color:#565656;line-height:20px"> Here in www.mostlikers.com has more Tutorials regarding web related things. </p>
                </a></td>
            </tr>
          </tbody>
        </table></td>
      <td valign="top" align="center" width="300" style="background-color:#f9f9f9"><br>
        <table width="100%" cellspacing="0" cellpadding="0">
          <tbody>
            <tr>
              <td valign="top" align="left" style="padding:0 10px 15px 20px;margin:0"><a href="http://mostlikers.2my4edge.com/" style="text-decoration:none;" >
                  <p style="padding:0;margin:0 0 7px 0;font-size:16px;color:#565656">DEMOS</p>
                  <p style="padding:0;margin:0;font-size:11px;color:#565656;line-height:20px"> And in DEMOS, we are showing everthing with demo examples repect to the tutorials.</p>
                </a></td>
            </tr>
          </tbody>
        </table></td>
    </tr>
  </tbody>
</table>
<table width="100%" cellspacing="0" cellpadding="0" style="max-width:600px;border:solid 1px #e6e6e6;border-top:none">
  <tbody>
    <tr>
      <td valign="top" align="center" style="text-align:center;background-color:#f9f9f9;display:block;margin:0 auto;clear:both;padding:15px 40px" bgcolor=""><p style="padding:0;margin:0 0 7px 0">
          <a title="mostlikers.com" style="text-decoration:none;color:#565656" href="http://www.mostlikers.com" target="_blank"><span style="color:#565656;font-size:13px">www.mostlikers.com</span></a>
        </p>
        <p style="padding:10px 0 0 0;margin:0;border-top:solid 1px #cccccc;font-size:11px;color:#565656">
          <a href="http://feeds.feedburner.com/mostlikers">SUBSCRIBE IN FEED</a>
            |  
          <a href="https://www.facebook.com/Mostlikers">FACEBOOK</a>
            |  
          <a href="https://plus.google.com/u/0/110408905103915967450/">GOOGLE+</a>
            |  
          <a href="https://twitter.com/karthickmuthu7">TWITTER</a>
        </p></td>
    </tr>
  </tbody>
</table>
</body>
</html>

Index.php :Bold Text Here

<title>Send email with html template using php mostlikers</title>
<style>
* {
    margin: 0;
    padding: 0;
}
.container {
    width: 800px;
    margin: 0 auto;
    border: 0px green dashed;
}
p {
    text-align: center;
    margin-bottom: 15px;
    padding: 5px;
    font-size: 16px;
}
input {
    padding: 10px;
    width: 500px;
    font-size: 16px;
    border: 1px #003366 solid;
}
textarea {
    width: 500px;
    height: 150px;
    resize: none;
    font-size: 16px;
    padding: 10px;
    border: 1px #003366 solid;
}
</style>

  <div align="center"><br><br><h2>Send email with html template using php</h2>
  <div>Demo <a href="http://www.mostlikers.com/2015/02/send-email-with-html-template-using-php.html">Tutorial Link</a>
   - mostlikers
    <a href="http://www.mostlikers.com">mostlikers.com</a><br><br></div> </div>
<div class="container">
  <form action="email.php" method="post">
    <p>
      <input type="text" required placeholder="Enter your firstname" name="firstname" />
    </p>
    <p>
      <input type="email" required placeholder="Enter your email"  name="email" />
    </p>
    <p>
      <input type="submit" name="send" value="Submit your Request">
    </p>
  </form>
</div>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- top big ads -->
<ins class="adsbygoogle"
     style="display:inline-block;width:1000px;height:120px"
     data-ad-client="ca-pub-9665679251236729"
     data-ad-slot="5194353429"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>

Hi,

If you want to learn about programming in PHP then we'll be happy to offer some guidance and help you learn but understand no-one here is going to write a solution for you - you simply won't learn anything that way.

If you want to get the submitted firstname into the body of the email you need to do something with your line $message = file_get_contents('template.php'); here, template.php will not be executed as a program, it will just be READ as a text file. It may as well be template.txt or template.htm.

I would probably do some hack here just to get it working but this would not be my normal way of doing an email in PHP at all - but that's just me. I use PHPMailer myself for any mailing that needs doing from PHP and don't personally use separate template files.

My hack to your current solution would go along the lines of editing your template.php to add 'tags' (e.g. where you want to put your name variable add the text %NAME% or something like that to the template) then use string manipulation functions on $message to replace each instance of the tag with the actual $firstname variable.

Recommended reading;
str_replace
mail

These manual pages if you haven't already looked at them should help you understand what the program is doing.

Have fun!
Ben

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.