PHP Email template for contact user and admin | 2my4edge

12 November 2014

PHP Email template for contact user and admin

I'm planned to post some new thing web related topic, many reader asking me how to build php email template for contact admin of the website and to visitor, So here we go to discuss about email template concept. just follow the below tutorials, that will be very helpful for coding design & developement.

gmail template

DOWNLOAD                         LIVE DEMO

my first post regarding this kind of email function is using PHPMailer 

INDEX.PHP
Form action will be in email.php file.
<div class="container">
  <form action="email.php" method="post">
    <p>
        <input type="text" required placeholder="Enter your name" name="firstname" />
    </p>
    <p>
        <input type="email" required placeholder="Enter email" name="email" />
    </p>

    <p>
        <input type="submit" name="send" value="Submit your Request">
    </p>
  </form>
</div>

EMAIL.PHP
inside the email.php file you have to give css as like inline css, than only that will reflect in email where you are receiving. 
<?php
if(isset($_POST['send']))
{
   extract($_POST); 
    $to="xxx@gmail.com,$email"; //change to your mail address $email is to visitor and xxx mail is for admin.
    $strSubject="2my4edge Email Template";           
    $message .= "<html>\n";
    $message .= '<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">&nbsp;</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="https://www.2my4edge.com" target="_blank">
          <img border="0" height="30" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWvOdIiG12ffCJuB4q3pygAo8JIVmr_4serpR20MRj6PzghHHaIqPdxhbWyLOlvntAvLoz_rQBUzXKQCUeMqN9V6S2jpw8ty6uVpsbJe2iechFfbT2reo9nbu5NaXlJCxJUcOk_IwrdYFx/s1600/new2.png" alt="2my4edge.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://demos.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">&nbsp;</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 '.$firstname.'
        </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.2my4edge.com"> www.2my4edge.com,</a>
          This is Email customised template. i hope this tutorial is really helpfula nd useful to you. </p></td>
    </tr>
  </tbody>
</table>

.................

.................



';
    $message .= "</body>\n";    
    $headers = 'MIME-Version: 1.0'."\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1'."\r\n";
    $headers .= "From: info@2my4edge.com"; 
    $mail_sent=mail($to, $strSubject, $message, $headers);  
    if($mail_sent)
        echo "<script>alert('Thank you. we will get back to you, check your spam too'); window.location='index.php';exit();</script>";
    else
        echo "<script>alert('Sorry.Request not send'); window.location='index.php';exit();</script>";
}
?>

I hope this post is really helpful to you. if you have any query please comment below we will help you as we can.


RELATED POSTS :





2 comments:

  1. in EMAIL.PHP page line 8 showing errors... how to solve this problem

    ReplyDelete

^