I am using this code to send an email from a contact form.
<?php
if (isset($_POST['contact_name']) && isset ($_POST['contact_email']) && isset($_POST['contact_text'])) {
$contact_name = $_POST['contact_name'];
$contact_email = $_POST['contact_email'];
$contact_text = $_POST['contact_text'];
if (!empty($contact_name) && !empty($contact_email) && !empty($contact_text)) {
$to = 'saurav.chill05@gmail.com';
$subject = 'Contact form Submitted.';
$body = $contact_name."\n".$contact_text;
$headers = 'From: '.$contact_email;
if (@mail($to, $subject, $body, $headers)) {
echo 'Thanks for contacting us.';
} else {
echo 'Sorry.';
}
} else {
echo 'All feild are required.';
}
}
?>
<form action="index.php" method="POST">
Name:<br><input type="text" name="contact_name"><br><br>
Email Address:<br><input type="text" name="contact_email"><br><br>
Message:<br>
<textarea name="contact_text" rows="6" cols="30"></textarea><br><br>
<input type="submit" value="Send">
</form>
This is not working on localhost. I tried to host this file on a hosting site and then filled the form it says thank you for contacting us, but i don't get any email. please help me with this.