0

I know this seems like it is a duplicate but please read first:

I have the following php code:

<?php

$to = '[email protected]';

$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$subject = $_POST['subject'];
$headers = "From: ".$email." \r\n";
$headers .= "Reply-To: ".$email."\r\n";

mail($to, $subject, $message, $headers); 

?> 

I think it's the standard email sending script. However, I face an interesting bug. My website is florin-pop.com and the emails are only sending when in the email input field I put something like this: [email protected] or [email protected] or anything before @florin-pop.com.

If I try to put a something different like [email protected] or even a real yahoo email address I don't get the email. Why? It's something wrong with my code? It may be from the hosting company? ( I use hostgator ).

EDIT:

If I change the Reply-To to the domains email address then it is working, but it is still not the perfect way to do it. If you press the reply button and forget about this trick, you will email yourself.

Code:

<?php

$to = '[email protected]';
$my_domain_email = '[email protected]';

$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$subject = $_POST['subject'];
$headers = "From: ".$email." \r\n";
$headers .= "Reply-To: ".$my_domain_email."\r\n";

mail($to, $subject, $message, $headers); 

?> 
9
  • Sounds like a most-likely-intentional restriction from the server sending the email. First thing to do would be to ask them if that's a thing they're doing. :p Commented May 6, 2015 at 22:29
  • And what can I do to fix it? Commented May 6, 2015 at 22:30
  • the issue is that the server that is being used to send the email isn't trusted, so you'll either a) never get the email b) get the email in a few weeks c) check your spam folder Commented May 6, 2015 at 22:30
  • 1
    To what is the "From" address ($email) set? Delivery failure could be related to the DMARC policy at yahoo.com. They are now "...bouncing emails sent as '@yahoo.com' addresses that aren't sent through Yahoo servers." Commented May 6, 2015 at 22:32
  • 1
    I changed the receiving email address from [email protected] to [email protected] and it seems that I get all the emails now. So it is something related to Yahoo. Commented May 6, 2015 at 22:42

1 Answer 1

1

In this case, delivery failure may be caused by Yahoo's adoption of the Domain-based Message Authentication, Reporting, and Conformance (DMARC) policy.

This means all DMARC compliant mail receivers (including Yahoo, Hotmail, and Gmail) are now bouncing emails sent as "@yahoo.com" addresses that aren't sent through Yahoo servers. [Yahoo]

Twitter, Facebook, Linked In, Paypal, AOL, Comcast and others have also adopted this policy. [Venture Beat]

A solution: Change the "From" header to an address at the server from which you are sending the email. This (correctly) indicates that the mail was sent from your server, and not from Yahoo. You can still use a user-submitted address in the "Reply-To" header so that the recipient can reply to the sender.

As a best practice, you should ... be using a domain you control in ... the "From:" header... [For example,] the site visitor's name is shown in the descriptive part of the "From:" header, and the "Reply-To:" header is set to the website visitor's address, but the actual address used in the "From:" header clearly indicates that your website is the origin of the message. [DMARC]

Sign up to request clarification or add additional context in comments.

4 Comments

I have changed the $headers = "From: ".$email." \r\n"; into the server's email, but I still can't get the emails to yahoo.
If I change the Reply-To then it is working fine. But still this is not very ok because if I press the reply button then it will put my own email again and I won't reply to the user. I have to manually do that.
It works when you change the "Reply-To" but not when you change the "From"? If it's a DMARC issue, you should be able to set the "Reply-To" however you like; it's the "From" header that needs to be set to the sending server.
I don't understand why changing the "Reply-To" header would have any effect. But, it's possible that I was mistaken and your problem is not DMARC-related at all.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.