PHP MAIL CODE

Php mail code example hope will help you...
we do this in two part
1. html form which send data
2. php code which give action to send data
see how

Example :- 


1. Html code :-

<form method="post" action="contactdata.php">
<p><label for="author">Your Name:</label>
<input type="text" class="textbox" value="Enter your name here..." onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Enter your name here...';}" name="name"> </p>
<p><label for="author">Email:</label>
 <input type="text" class="textbox" value="Enter your email here..." onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Email';}" name="email"> </p>
 <p><label for="author">Message:</label>
<textarea value="Enter your message here..." onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Message';}" name="msg">Enter your message here...</textarea> </p>
<input name="submit" type="submit" id="submit" value="Submit">
 </form>




Now we are going to create php code file name contactdata.php


                   <?php 
 $to = "youremail@domain.com";  // modify with your email id
 $from = $_REQUEST['email'] ; 
 $name = $_REQUEST['name'] ; 
 $headers = "From: $from"; 
 $subject = "Site Contact Form"; 

 $fields = array(); 
 $fields{"name"} = "name"; 
 $fields{"email"} = "email"; 
 $fields{"msg"} = "msg"; 

 $body = "We have received the following information:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); } 

 $headers2 = "From: noreply@YourCompany.com"; 

 $subject2 = "Thank you for contacting us"; 

 $autoreply = "Thank you for contacting us. Somebody will get back to you as soon as possible, usualy within 48 hours. If you have any more questions, please consult our website at www.yourwebsite.com";


 if($from == '') {print "You have not entered an email, please go back and try again";} 
 else { 
 if($name == '') {print "You have not entered a name, please go back and try again";} 
 else { 
 $send = mail($to, $subject, $body, $headers); 
 $send2 = mail($from, $subject2, $autoreply, $headers2); 
 if($send) 
 {print "<span class='color'>Thank You for your FeedBack. <a href='your homepage link'>Click Here</a> to go back home page</span>";} 
 else 
 {print "Sorry Your Message Is Not Delivered. Email Us At : youremail@domain.com";} 
 }
}
 ?> 

Free Responsive HTML5 CSS3 Website Templates

Free Responsive HTML5 CSS3 Website Templates

looking for Responsive website templates ? this is right place for free Responsive templates

Download the latest CSS3 Responsive website templates provided by w3layouts. This templates are Mobile friendly and cross device supportive. Download and start your website which is responsive and looks good in Mobile or Tablate. By using this responsive website templates you can avoid building seperate website for Mobile devices.