I have a contact form in my website, using the php below to delivery the form result as email.
My problem is that whenever someone uses the contact form, I receive the email as spam, instead of the normal inbox folder. Could the problem be in the php above?
//Need to submit the form.
echo "error; you need to submit the form!";
$name = $_POST['name'];
$visitor_email = $_POST['email'];
$message = $_POST['message'];
echo "Your Name and Email is required, please try again!";
echo "Bad email value!";
$email_from = 'firstname.lastname@example.org';//<== this websites email, I shall update this when we get the domain name.
$email_subject = "New Form Submission SiC";
$email_body = "You have received a new quick message from $name.\n\n".
"Here is the message:\n
$to = "email@example.com";//<== where it will send the message to, let me use my email for now.
$headers = "From: $email_from \r\n";
$headers .= "Reply-To: $visitor_email \r\n";
//Send the email!
//done. redirect to thank-you page.
// Function to validate against any email injection attempts
$injections = array('(\n+)',
$inject = join('|', $injections);
$inject = "/$inject/i";