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:
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?
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)
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.
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.
Email services today are quite strict on things like SPF and DKIM, with so many mail scams going on. So you will need to configure your DNS records to tell which domains and IPs are allowed to send mail from your domain.
The issue here is that the emails are being sent directly from the server via PHP mail, which is not advised as itâs an old, outdated method, and due to increasingly high restrictions, it might not pass the SPF validation.
The solution would be to set the form to send from an actual email address via our SMTP.
They have provided me with PHP code that I need to configure, but I have not tried that yet to see if it works.
I hope this is helpful information for anyone else using the PHP mail function, especially if they are setting the sending email address to be the email address entered by a site visitor on a website form.
To clarify, were you attempting to send emails from your code without providing the necessary authentication details to the email server, valid credentials (username, password), hostname, port, and SSL configuration?
Thatâs what I thought, and I couldnât believe it!
In my opinion, you have a very permissive email service provider!
For years, Iâve used several providers, from small ones to global services like Gmail or Zoho Mail, and none of them allow emails to be sent from a website without proper identification to their server.
If thatâs what you are trying to do, forget it. Use an address from the actual domain as the sender, you can set the âReply toâ address to that of the visitor.
By using their address as the âfromâ you are effectivly spoofing their address, which any reputable email service will rightly reject.