Like Us on Facebook

Send Mail Using PHP

We have seen in many website, their is a contact form and you can fill all the details and submit. This form details goes into a particular mail address with your all details. So this post is about Mail function using PHP. This mail function is very easy to develope. Now you can sending mail from your website to user mail address. It can be your contact details or any message. But this post only works in web server. So lets start

                   
 

The script contain only one file.

index.php 
 



HTML Code
<form action="" method="post">
                    
                   
<div class="row control-group">
                        <div>
                            <label>
Name</label>
                           
<input type="text" class="form-control" placeholder="Name" id="name" name="name" required>
                            <p class="help-block text-danger"></p>
                        </div>
                    </div>
                    <div class="row control-group">
                        <div>
                            <label>
Email Address</label>
                           
<input type="email" class="form-control" placeholder="Email Address" id="email" name="email" required>
                            <p class="help-block text-danger"></p>
                        </div>
                    </div>
                    
                    <div class="row control-group">
                        <div>
                            <label>Message</label>
                           
<textarea rows="5" class="form-control" placeholder="Message" id="message" name="message" required></textarea>
                            <p class="help-block text-danger"></p>
                        </div>
                    </div>
                   
                   
                    <br>
                   
                    <div class="row">
                        <div>
                           
<button type="submit">Send</button>
                        </div>
                    </div>


 </form>
 

PHP Code
<?php

      if ($_SERVER["REQUEST_METHOD"] == "POST") 
       { 
 
           $name=$_REQUEST['name'];
           
$email=$_REQUEST['email'];
           
$message=$_REQUEST['message'];
           $to = $email;
           
$subject = "Your message from website";
           
$text="Name:$name \n Email:$email \n Message:$message";
           
$headers = "From: Title"; 
         
 $sent = mail($to, $subject, $text, $headers) ; 
 
        }

?>

Posted By UandBlog

UandBlog is a Global Leading source of Finance, Health, Lifestyle, Technology, Gaming and Programing and other information, it is a fastest growing blog for all , for latest post or information like us on facebook , follow on Twitter, Google+ and Pinterest.

Comments ( 0 )

    Leave a comment..

    Click to login.