0

Why does our "Contact Us" form code fail to deliver the users email to our gmail account
if sender uses a yahoo email address?

To test we reduced the code to a minimum and only changed the From address.

Works: From myemail@mywebsite.com
Fails: From myemail@yahoo.com
(actual email addresses were used in each case)
Yes, we looked in the spam folder and all others as well. Not there.
Here is the code:

<?php $name = "Me";
$email = "myemail@yahoo.com";
$message = "test message 1 on 6-7-20";
$formcontent="From: $name \n Message: $message";
$recipient = "mysiteadmin@gmail.com";
$subject = "test message on 6-7-20";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Sent to ".$recipient." from ".$email";
?>
Fran_3
  • 378
  • 1
  • 3
  • 12
  • 1
    Which smtp server are you using? – Maritim Jun 07 '20 at 17:05
  • GoDadaddy linux server host the site -- Mailed by: a2plcpnl0299.prod.iad2.secureserver.net – Fran_3 Jun 07 '20 at 18:29
  • You have to use an SMTP server which can send mail on behalf of the sender address you're using. For that you could for instance use PHPMailer. Possible duplicate of https://stackoverflow.com/questions/19555650/php-mail-vs-yahoo-can-someone-simply-explain-steps-required-for-yahoo-to-rece – Maritim Jun 08 '20 at 08:38
  • Does this answer your question? [Php mail() vs Yahoo: Can someone Simply Explain Steps required for YAHOO to receive mail from php mail function?](https://stackoverflow.com/questions/19555650/php-mail-vs-yahoo-can-someone-simply-explain-steps-required-for-yahoo-to-rece) – Maritim Jun 08 '20 at 08:38

0 Answers0