Php电子邮件功能无法正常工作

时间:2021-07-01 21:29:05

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

我知道这似乎是重复但请先阅读:

I have the following php code:

我有以下PHP代码:

<?php

$to = 'myemail@yahoo.com';

$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: blahblah@florin-pop.com or mama@florin-pop.com or anything before @florin-pop.com.

我认为这是标准的电子邮件发送脚本。但是,我面临一个有趣的错误。我的网站是florin-pop.com,电子邮件只发送到电子邮件输入字段时我输入的内容如下:blahblah@florin-pop.com或mama@florin-pop.com或之前的任何内容@ florin-pop.com 。

If I try to put a something different like test@yahoo.com 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 ).

如果我尝试放一些不同的东西,如test@yahoo.com,甚至是真正的雅虎电子邮件地址,我都没有收到电子邮件。为什么?我的代码有问题吗?它可能来自托管公司? (我使用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 = 'myemail@yahoo.com';
$my_domain_email = 'myemail@mydomain.com';

$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); 

?> 

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.

在这种情况下,雅虎采用基于域的消息身份验证,报告和一致性(DMARC)策略可能导致传递失败。

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]

这意味着所有符合DMARC标准的邮件接收器(包括Yahoo,Hotmail和Gmail)现在正在弹出作为“@ yahoo.com”地址发送的电子邮件,这些地址不是通过Yahoo服务器发送的。 [雅虎]

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

Twitter,Facebook,Linked In,Paypal,AOL,康卡斯特等也采用了这一政策。 [创业节拍]

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.

解决方案:将“发件人”标题更改为发送电子邮件的服务器上的地址。这(正确)表示邮件是从您的服务器发送的,而不是从Yahoo发送的。您仍然可以在“回复”标题中使用用户提交的地址,以便收件人可以回复发件人。

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]

作为最佳实践,您应该...使用您控制的域...“发件人:”标题... [例如,]网站访问者的名称显示在“发件人:”的描述部分中标题,并且“回复:”标题设置为网站访问者的地址,但“发件人:”标题中使用的实际地址清楚地表明您的网站是邮件的来源。 [DMARC]

#1


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

在这种情况下,雅虎采用基于域的消息身份验证,报告和一致性(DMARC)策略可能导致传递失败。

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]

这意味着所有符合DMARC标准的邮件接收器(包括Yahoo,Hotmail和Gmail)现在正在弹出作为“@ yahoo.com”地址发送的电子邮件,这些地址不是通过Yahoo服务器发送的。 [雅虎]

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

Twitter,Facebook,Linked In,Paypal,AOL,康卡斯特等也采用了这一政策。 [创业节拍]

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.

解决方案:将“发件人”标题更改为发送电子邮件的服务器上的地址。这(正确)表示邮件是从您的服务器发送的,而不是从Yahoo发送的。您仍然可以在“回复”标题中使用用户提交的地址,以便收件人可以回复发件人。

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]

作为最佳实践,您应该...使用您控制的域...“发件人:”标题... [例如,]网站访问者的名称显示在“发件人:”的描述部分中标题,并且“回复:”标题设置为网站访问者的地址,但“发件人:”标题中使用的实际地址清楚地表明您的网站是邮件的来源。 [DMARC]