Email Form does not send messages

The email form on my contact page isn’t working.
It has 3 input fields: name, email, message, and a **send button; **when clicked, the form should change to a “message sent” message and the send button changes to a “Back” button.

For some reason, i only receive an email in my inbox if the email field is my own personal email, the same one it sends to. But, if any other email is typed in, i don’t get the message.

Also, after "send " is clicked, the “message sent” message & back button don’t show up.

this is my PHP file:
<?php
$sendTo = "myEmail@yahoo.com";
$subject = “Website Response Form”;

$headers = “From: " . $_POST[“name”] .”<" . $_POST[“email”] .">
";
$headers .= "Return-Path: " . $_POST[“email”]. "
";
$message = $_POST[“message”];

mail($sendTo, $subject, $message, $headers);
?>

is there something wrong with it?

help, please.

try it without the “Reurn-path”

The reason is because you are trying to spoof the from header. Let’s say your domain is yourdomain.com. Now, a user comes along and tries to contact you using your form and their email address is joe@gmail.com

When you send an email from your POP mailserver at yourdomain.com, the SMTP server at yourdomain.com receives the message and immediately knows that it is not coming from gmail.com’s servers, so it assumes it is spam and blocks it at the server.

The proper way would be to use a real email address that is on your server as the from email addr and put the from name as something like “WebsiteUser”. Then, use the email that they entered as the Reply-to header, so you can just hit the “reply” button in your email client to reply to them.

Also, it is very important that you strip out any newline characters “
” from the input that you get from the form otherwise a spammer could inject a “bcc” header into your email and use it to send spam to other people.