Tuesday, 6 August 2013

How to send Email By php when user fill registration Form


NOTE : you need to download  "class_email.php" file and save it in your main folder.

Here html form for Users:

********************************index.html***********************


<h5>Registraton Form</h5>
<form method="post" action="insert.php" id="ff" class="well span2" style="padding:10px 10px 10px 10px;margin-left:0px;margin-top:0px" >
<label>Your Name :</label><input type=text class="span2" required id="user" name="user" placeholder="Name :">
<label>Mobile No :</label><input type=text class="span2" required name="mob" id="mob" placeholder="Mobile No :">
<label>Email ID :</label><input type=text class="span2" required name="email" id="email" placeholder="Email ID :">
<label>Select Course</label>
<select class="span2" id="crs" name="crs" style="background:white;border:1px solid white;color:black">
<option value="" selected>-select-</option>
<option value="Career Courses">Career Course</option>
<option value="Training Programs">Training programs</option>
</select>
<label>Select Technology</label>
<select class="span2" id="tech" name="tech" style="background:white;border:1px solid white;color:black">
<option value="" selected>-select-</option>
<option value="android">Android</option>
<option value="C#net">.Net C#</option>
<option value="aspNet">Asp.Net</option>
<option value="phpMsql">Php,MySql</option>
<option value="jquery">Jquery</option>
<option value="htmlJavaCss">Html,JavaScript,CSS</option>
<option value="java">Java</option>
<option value="AjaxWebService">Ajax,WebServices</option>
<option value="WordPress">WordPress</option>
<option value="LinqWpfMvc">Linq,Wpf,Mvc</option>
</select>
<button id="bt" class="btn btn-primary">Submit</button>
<input type=reset value=reset class="btn">
</form>





**************************index.html ended here ***********************


Here is php Code sending Mail.


php file name : insert.php

<?php


$name = $_POST["user"];
$mobile = $_POST["mob"];
$email = $_POST["email"];
$course = $_POST["crs"];
$tech = $_POST["tech"];

//echo "hi, Your name is :$name \n mob:$mobile \n email:$email \n course : $course \n tech:$tech";

include( 'class_email.php');

     $ee= new email();

//below is your Server details with port number.

  $ee->set_server('smtp.gmail.com', 465); //465,597,25 ()


//In below line you have to specify your google valid email and password
  $ee->set_auth('abc@gmail.com','password');


  $ee->set_sender( 'sender Details here ', 'sender Mail here' );

//In array() function mention your list to whom you want to send email: you can specify more than one
//like below

$send_to =array('abc@yahoo.com','xyz@gmail.com','pqr@gmail.com');
  $subject = "Enquiry Mail:GEdutech";
  $body="<div style='border:2px solid blue'><table border='0' cellpadding='10'> <tr> <td>Enquiry Name  </td><td>$name</td></tr>
  <tr> <td>Mobile No: </td><td>$mobile</td></tr>
   <tr> <td>Email :  </td><td>$email</td></tr>
  <tr> <td>Course </td><td>$course</td></tr>
   <tr> <td>Technology  </td><td>$tech</td></tr></table> </div>";


  if( $ee->mail($send_to, $subject,$body))
  {
echo true;
}
 else
 {
echo false;
}


?>


1 comments:

  1. Hi, Its really very informative and useful blog..Thanks for sharing this useful information about PHP Course.

    PHP Course in Chennai

    ReplyDelete