Help with contact form

Hi,
I have a very basic cont form which only works when using Firfox.
I have tested it with Chrome, Safari and Android but I don’t receive an email from any of these. Not sure what’s going on here.

<?php
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$call = $_POST['call'];
$type = $_POST['type'];
$message = $_POST['message'];
$formcontent=" From: $name \n 
Phone: $phone \n 
Type: $type \n 
Message: $message";
$recipient = "[email protected]";
$subject = "Book_a_Course Form";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Your message has been sent successfully.  Thank You!" . " -" . "<a href='https://nobullab.com.au/' style='text-decoration:none;color:#ff0099;'> Return Home</a>";
?>

Help …

Unless there’s an error in the form markup, which you didn’t post, there’s nothing that is browser dependent in the posted code.

The only apparent related problem in the posted code is that these emails are not being sent from the email address that was entered in the form. They are being sent from the mail server at your web hosting and the domain in the From: mail header must correspond to the domain at the sending mail server, either directly or through DNS records at the sending mail server. You can put the email address that was entered in the form into a Reply-to: mail header, after you have validated that it is only and exactly one properly formatted email address, to prevent mail header injection.

You also need to apply htmlentities() to all the dynamic values, after trimming and validating them, to help prevent cross site scripting if the emails are being viewed using a browser.

I have experienced this same problem so here are some suggestions that I used to solve.

Ensure you include header lines in your email send, here are the headers I use

$headers = “MIME-Version: 1.0” . “\r\n”;

$headers .= “Content-type: text/html; charset=utf-8” . “\r\n”;

$headers .= “X-Priority: 3\r\n”;

$headers .= “From: your email send address@your_mail_server.com” . “\r\n”;

$headers .= " X-Mailer: PHP/" . phpversion();
check with internet blacklist sites to see if your mail server is blacklisted you can use site

Email Blacklist Check - IP Blacklist Check - See if your server is blacklisted

Try sending a very simple test message, I use

<?PHP $sender = '[email protected]'; $recipient = '[email protected]'; $subject = "php mail test"; $message = "php test message"; $headers = 'From:' . $sender; if (mail($recipient, $subject, $message, $headers)) { echo "Message accepted"; } else { echo "Error: Message not accepted"; } ?>
Sponsor our Newsletter | Privacy Policy | Terms of Service