I want to create a contact form for the website im working on which uses PHP and Recaptcha. Everything works fine including Recaptcha and when I hit send it shows message successfully sent, but I'm not getting any mail in the account given.
I wanted to know which mail does the contact form send the mail from?. Before I was testing it in xampp, I just modified the sendmail.ini
and entered my Gmail details and it used to work, but now I'm hosting this in my hosting space, but I don't know if I will have to create a domain mail and link the two PHP somehow.
<!--Section heading-->
<h2 class="h1-responsive font-weight-bold text-center my-4">Contact us</h2>
<!--Section description-->
<p class="text-center w-responsive mx-auto mb-5">Do you have any questions? Please do not hesitate to contact us directly. Our team will come back to you within
a matter of hours to help you.</p>
<div class="row">
<!--Grid column-->
<div class="col-md-9 mb-md-0 mb-5 mx-auto">
<form action="" method="post">
<!--Grid row-->
<div class="row">
<!--Grid column-->
<div class="col-md-6">
<div class="md-form mb-0">
<input type="text" id="name" name="name" class="form-control"required>
<label for="name" class="">Your name</label>
</div>
</div>
<!--Grid column-->
<!--Grid column-->
<div class="col-md-6">
<div class="md-form mb-0">
<input type="text" id="email" name="email" class="form-control" required>
<label for="email" class="">Your email</label>
</div>
</div>
<!--Grid column-->
</div>
<!--Grid row-->
<!--Grid row-->
<div class="row">
<div class="col-md-12">
<div class="md-form mb-0">
<input type="text" id="subject" name="phone" class="form-control"required>
<label for="subject" class="">Phone No.</label>
</div>
</div>
</div>
<!--Grid row-->
<!--Grid row-->
<div class="row">
<!--Grid column-->
<div class="col-md-12">
<div class="md-form">
<textarea type="text" id="message" name="message" rows="2" class="form-control md-textarea" required></textarea>
<label for="message">Your message</label>
</div>
</div>
</div>
<div class="row">
<!--Grid column-->
<div class="col-md-12">
<div class="md-form">
<div class="g-recaptcha" data-sitekey=></div>
<input type="submit" name="submit" value="Send Message" class="submit-btn">
</div>
</div>
</div>
<!--Grid row-->
</form>
<div class="status">
<?php
if(isset($_POST['submit']))
{
$User_name = $_POST['name'];
$phone = $_POST['phone'];
$user_email = $_POST['email'];
$user_message = $_POST['message'];
$email_from = '';
$email_subject = "New Form Submission";
$email_body = "Name:$User_name.\n".
"Phone No: $phone.\n".
"Email Id: $user_email.\n".
"User Message: $user_message.\n";
$to_email = "fekecih@drmail.net";
$headers = "From: $email_from \r\n";
$headers .="Reply-To: $user_email\r\n";
$secretKey =
$responseKey = $_POST['g-recaptcha-response'];
$userIP = $_SERVER['REMOTE_ADDR'];
$url = "https://www.google.com/recaptcha/api/siteverify?secret=$secretKey&response=$responseKey&remoteip=$userIP";
$response = file_get_contents($url);
$response = json_decode($response);
if ($response->success)
{
mail($to_email,$email_subject,$email_body,$headers);
echo "Message sent Successfully";
}
else
{
echo "<span>Invalid Captcha, Please Try Again,</span>";
}
}
?>
</div>
</div>
</div>
</section>