I am first time working on web development using just html. I have a webiste and i want to have an information submit form which must send an email without opening outlook. I try to do so uing a http POST request and handling it using PHP.
The problem is it do not send the email. I don't know wy.
My SendEmail.php file is:
<?php
if(isset($_POST['submit']))
{
$to = "shekhar.paris@gmail.com"; // this is your Email address
$from = $_POST['email']; // this is the sender's Email address
$first_name = $_POST['name'];
$subject = "Form submission";
$message = $first_name . " " . " wrote the following:" . "\n\n" . $_POST['message'];
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
echo "Mail Sent. Thank you " . $first_name . ", we will contact you shortly.";
// You can also use header('Location: thank_you.php'); to redirect to another page.
}
?>
My html is :
<div class="contact">
<div class="container">
<div class="row">
<div class="col-sm-12">
<h4>Please Contact With Us For Any Kind Of Information></h4>
<form id="contactform" action="SendEmail.php" method="post" class="validateform" name="send-contact">
<div class="row">
<div class="col-lg-4 field">
<input type="text" name="name" placeholder="* Your Name" data-rule="maxlen:4" data-msg="Please enter at least 4 chars" />
</div>
<div class="col-lg-4 field">
<input type="text" name="email" placeholder="* Your Email" data-rule="email" data-msg="Please enter a valid email" />
</div>
<div class="col-lg-4 field">
<input type="text" name="subject" placeholder="Subject" data-rule="maxlen:4" data-msg="Please enter at least 4 chars" />
</div>
<div class="col-lg-4 field">
<input type="text" name="ContactNumber" placeholder="* Contact Number" data-rule="required" data-msg="Please enter your number" />
</div>
<div class="col-lg-12 margintop10 field">
<textarea rows="12" name="message" class="input-block-level" placeholder="* Your message here..." data-rule="required" data-msg="Please write something"></textarea>
<p>
<button name="submit" value="submit" class="btn btn-theme margintop10 pull-left" type="submit">Submit message</button>
</p>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
Could some one please help me in sending the email ?