I have these exact same PHP contact form codes on 2 different servers. 1 is working as intended, but the other is returning the error message instead of the success message. Also, email is not sent to me.
Contact.php codes as follows:
<?php
ob_start();
if(isset($_POST['submit']))
{
$name = $_POST['name'];
$email = $_POST['email'];
$query = $_POST['message'];
$email_from = $name.'<'.$email.'>';
$to="email@gmail.com";
$subject="Enquiry";
// $headers = 'MIME-Version: 1.0' . "\r\n";
//$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From: ".$email_from."\r\n";
$message="
Name:
$name
Email:
$email
Message:
$query
";
if(mail($to,$subject,$message,$headers))
header("Location: http://www.website.com/contact.php?msg=Successful Submission! Thank you for contacting us.");
else
header("Location: http://www.website.com/contact.php?msg=Error Sending Email!");
}
?>
I'm wondering if it is permissions/server problem? Any help will be greatly appreciated! Thanks!