Form submissions not reaching Gmail addresses

I have a website with a number of forms for contacting club committee members (to avoid their email addresses appearing on the internet). I am finding that form submissions do not reach those who have Gmail addresses, not even into their junk/spam folders.

In PHP, after cleaning and some validation, I am constructing and sending the message as follows:

$emailContent = "From 'Contact Us' web page\n\n"
."Message:\n"
."   {$Message}\n\n"
."Name:\n"
."   {$Name}\n\n"
."Email:\n"
."   {$Email}\n\n"
."Phone:\n"
."   {$Phone}\n\n"
."";

$emailHead = "From:webmaster@xxxxxxxxx.co.uk\n"
."MIME-Version: 1.0\n"
."Content-type: text/plain; charset=utf-8\n"
."Content-transfer-encoding: 8bit\n";

mail("xxxxxxxxx@gmail.com","Website Form Submission",$emailContent,$emailHead);

Header("Location:contact-thanks.html");

This works fine for various email addresses that are not Gmail. However for a Hotmail address I receive a warning “We can’t verify that this email came from the sender so it might not be safe to respond to it”, with a link to this Microsoft page:
https://support.microsoft.com/en-gb/office/phishing-and-suspicious-behavior-in-outlook-0d882ea5-eedc-4bed-aebc-079ffa1105a3

In the email head, messages are constructed to appear to be from the webmaster’s email address. I have read that this reduces the chance of messages being regarded as spam because it’s on the same domain as the website.

Is there something I can do so messages from website forms will be received by Gmail addresses?

  1. Does the webmaster’s email actually exist?
  2. Is the server’s mail daemon configured to actually send it as the webmaster, or to make it ‘appear’ like it’s from the webmaster (and thus triggers every “This is spam/fake/malware” alarm in mail servers)
1 Like

Many thanks. Yes, the webmaster’s email address does exist.

I will try to find out about the server’s mail daemon. When an email is received, it appears to come from webmaster@xxxxxxxxx.co.uk so that $emailHead seems to be working.

Yeah, but if the mail daemon’s configured to identify itself as example.com and its sending emails as notexample.co.uk without a relay between them, it’s going to look to gmail like someone’s faking a notexample.co.uk email.

2 Likes

Thanks again.

The issue seems to be with the SPF (Sender Policy Framework) text file, perhaps because emails from the website forms are sent from a different IP address to ordinary emails. I have raised a support ticket with the hosting company.

1 Like