Tuesday 16 July 2013

PHP Email script

 PHP MAIL SCRIP:

<?php

session_start();
ob_start();

    $name = $_POST['name']; // required
    $lastname = $_POST['lastname']; // required
    $email = $_POST['email']; //  required
     
   
  


$to1 = $_POST['email'];
$subject = "Test";
$message = "";
$from = "";
$headers = "From: $from";
// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

$content = '
    <html>
    <head>
      <title>Bangalore Secretary Service</title>
    </head>
    <body>
    <table width="500" border="1" cellspacing="0" cellpadding="3"  style="border:2px solid #0082b8">
  <tr>
    <td width="200"  style="color:#0b95c5; font-size:16px">Name:</td>
    <td width="142" style="color:#666; font-size:13px">'.$name.'</td>
  </tr>
  <tr>
    <td style="color:#0b95c5; font-size:16px">Last Name:</td>
    <td style="color:#666; font-size:13px">'.$lastname.'</td>
  </tr>
 
  
  <tr>
    <td style="color:#0b95c5; font-size:16px">Email:</td>
    <td style="color:#666; font-size:13px">'.$email.'</td>
  </tr>
 

</table>
   
  
    </body>
    </html>';
   


$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'To: TESTMAil <prakasamonline@gmail.com>' . "\r\n";
$headers .= 'From: '.$_POST['name'].' <'.$_POST['email'].'>' . "\r\n";




//@mail($to, $subject, $content, $headers);
//$to = 'info@webdesignindia-vistas.com,anthony@vistasad.com';
@mail($to='prakasamonline@gmail.com', $subject, $content, $headers);

echo "<script language=\"javascript\" type=\"text/javascript\">
window.location = \"email.html\";
</script>
";

?>

Sample HTML :

<!DOCTYPE html>
<html>
    <head>
    <meta charset="utf-8">
     <title>test mail</title>
  </head>

  <body>
  <div class="wrapper">

<div><form class="contact_form" action="mail.php" method="post" name="contact_form">
    <ul>
      
        <li>
            <label for="name">Name:<span class="readtext">*</span></label>
            <input type="text"  required  name="name" />
        </li>
         <li>
            <label for="name">Last Name:<span class="readtext">*</span></label>
            <input type="text"  required name="lastname" />
        </li>
  
        
        <li>
            <label for="email">Email:<span class="readtext">*</span></label>
            <input type="email" name="email"  required />
            <span class="form_hint">Proper format "name@something.com"</span>
            <p style="position:relative; right:-157px;"><span class="readtext">Note:</span> Please send in your emails through your official company email ID, we will not be able to respond to personal email ID’s
</p>
        </li> 
        
            <button class="submit"  type="submit">Submit</button>
        </li>
    </ul>
          
                   </form>
                      </div> <!-- END request form -->    
    </section> <!-- Content end -->

       
      
      
  </body>
 
  </html>

No comments:

Post a Comment