I have a form on my GoDaddy website that uses the PHP mail() function to send an email with the completed form to a Gmail account and it's worked just fine for several years. I recently upgraded from PHP 5.2 to PHP 5.6 and then to PHP 7 and now the form is broken in a strange way. It seems to work unless the user completes the From: field with a Yahoo email address.
To help explain, here is a little script I've been using to troubleshoot:
<?php
$to = 'flyfishing@gmail.com';
$subject = 'Test mail';
$message = 'Hello! This is a simple test email message.';
$from = 'email@email.com';
$headers = 'From:' . $from;
mail($to,$subject,$message,$headers);
echo 'Mail Sent.';
?>
Notice that flyfishing@gmail.com is where I need the completed form to go (it's my fly fishing club email account) and email@email.com is the email address of the person who completed the form. The script seems to work just fine unless email@email.com is a Yahoo email account. In that case, there are no error messages but the form just never shows up at Gmail. Lost in cyberspace.
I don't pretend to understand PHP very well, but I've searched for a solution for a couple of days without success. Any suggestions? I would prefer to just make the mail function work, but I understand there are alternative ways to send email from a form on GoDaddy. Any help would be greatly appreciated.
Many thanks, Dave