I am having a problem with my contact form and the php mail() function. For some reason, they work for every email address (@gmail, @yahoo, @outlook and even @facebook!) except the old dreaded hotmail. I am just curious as to where my code is missing something. I have checked the mail servers and there is apparently no issue with hotmail addresses.
The email does not even get delivered to the spam/junk folder (it does not reach hotmail). I had a look online and some say to change the headers to avoid being caught in the spam filter. Any pointers to this?
PHP CODE
<?php
header('Content-Type: application/json charset=utf-8');
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$from = 'companyname@mail.com';
$to = 'myemail@hotmail.com';
$subject = $name . ' has sent you a message';
$human = $_POST['antispam'];
$body = "From: $name
E-Mail: $email
Message:
$message";
if (isset($_POST['name']) && $human == '4') {
if (mail ($to, $subject, $body, $from)) {
echo '{"status":"1"}';
} else {
echo '{"status":"0"}';
}
}
else
{
echo '{"status":"2"}';
}
?>
The if statements is just a check if all forms are valid and the anti spam (2+2) is correctly entered. nothing much to do in this part. The issue I guess is somewhere in the header