Tuesday, 16 July 2013

PHP Email script




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


$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\";


Sample HTML :

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

  <div class="wrapper">

<div><form class="contact_form" action="mail.php" method="post" name="contact_form">
            <label for="name">Name:<span class="readtext">*</span></label>
            <input type="text"  required  name="name" />
            <label for="name">Last Name:<span class="readtext">*</span></label>
            <input type="text"  required name="lastname" />
            <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
            <button class="submit"  type="submit">Submit</button>
                      </div> <!-- END request form -->    
    </section> <!-- Content end -->