简体   繁体   English

无法将邮件发送到@gmail

[英]Cant send mail to @gmail

I have this code for sending mail 我有此代码用于发送邮件

$to = "account@gmail.com";
$subject = "mail title";
$message = "mail content";

$from_mail = "sender@site.com";          

$headers = 'MIME-Version: 1.0\r\n'.
           'From: '.$from_mail.'' . "\r\n" .
           'Reply-To: '.$from_mail.'' . "\r\n" .
           'Content-type: text/html; charset=utf-8' . "\r\n";
           'X-Mailer: PHP/' . phpversion(); 

This code sends mails for any mail provider except @gmail . 该代码为@gmail以外的任何邮件提供者发送邮件。

What may be reason for this 这可能是什么原因

My guess—as is others—is that your message went to a SPAM folder. 与其他情况一样,我的猜测是您的邮件已发送到SPAM文件夹。 But it is unclear what machine this script is on. 但是尚不清楚此脚本在什么计算机上运行。 Is this your localhost test environment or another isolated development server? 这是您的localhost测试环境还是其他隔离的开发服务器? Or is it a functioning production server? 还是功能正常的生产服务器?

If this is a localhost or other isolated test environment, my guess is that Gmail—and possibly even AOL—are blocking your mail as potential SPAM. 如果这是一个localhost或其他隔离的测试环境,我猜测Gmail甚至可能是AOL都将您的邮件作为潜在的SPAM进行阻止。

But if this is a forward facing production server, the problem can most likely traced to a missing PTR (aka: Reverse DNS record) for the IP address the machine is on. 但是,如果这是面向前的生产服务器,则该问题很可能是由于机器所在的IP地址缺少PTR(aka:反向DNS记录)引起的。

As explained on this site . 本网站所述

PTR records are mainly used to check if the server name is actually associated with the IP address from where the connection was initiated. PTR记录主要用于检查服务器名称是否实际上与从其发起连接的IP地址相关联。

Meaning, many mail servers are setup to simply mark any message as SPAM if they cannot connect a valid PTR record to the domain. 这意味着,如果许多邮件服务器无法将有效的PTR记录连接到域,则它们会将它们简单地标记为垃圾邮件。

Also, if this is a production server with multiple IP addresses, there might be an issue with your SPF (Sender Policy Framework) record. 另外,如果这是具有多个IP地址的生产服务器,则您的SPF(发送方策略框架)记录可能存在问题。 Read up more on this site : 在此网站上阅读更多内容

Even more precisely, SPFv1 allows the owner of a domain to specify their mail sending policy, eg which mail servers they use to send mail from their domain. 更准确地说,SPFv1允许域的所有者指定其邮件发送策略,例如,他们使用哪些邮件服务器从其域发送邮件。

So an SPF record is a DNS record that basically says: “Okay, you think you are an e-mail from xyz.com IP address 1.2.3.4 ? 因此,SPF记录是一个DNS记录,基本上说:“好吧,您认为您是来自xyz.com IP地址1.2.3.4的电子邮件? Let me look up your SPF record, and hey! 让我查看您的SPF记录,嘿! The SPF record says that any e-mail sent from the IP address of 1.2.3.4 is cool with xyz.com ! SPF记录说, xyz.com从IP地址1.2.3.4发送的任何电子邮件都很酷! You are not SPAM.” 您不是垃圾邮件。”

While there are other factors such as delays in delivery or receipt when dealing with e-mails, I am pretty confident resolving the PTR and the SPF status of the IP address you are sending from will clear this up. 尽管还有其他一些因素,例如在处理电子邮件时延迟发送或接收,但我非常有信心解决您从其发送的IP地址的PTR和SPF状态将清除此问题。 This is not a coding issue but a networking and mail infrastructure configuration issue on your side. 这不是编码问题,而是您身边的网络和邮件基础结构配置问题。

Because of spam, email providers are getting more and more stringent about accepting mail. 由于垃圾邮件,电子邮件提供商对接受邮件的要求越来越严格。

If you are using shared hosting, then probably that email server will have a bad reputation and you may have to change provider or use whatever mail service they provide. 如果您使用共享主机,则该电子邮件服务器的信誉可能很差,您可能必须更改提供商或使用其提供的任何邮件服务。 emailing support may be a good start 电子邮件支持可能是一个好的开始

Many times, mail is not completely blocked but delayed. 很多时候,邮件没有被完全阻止而是被延迟。 I would wait a while and check if email gets there. 我会等一会儿,然后检查电子邮件是否到达那里。 I would also check the mail queue and see what the status of the email is 我还要检查邮件队列,看看电子邮件的状态是什么

make sure that you have the appropriate DNS records: _ dkim _ spf _ dmarc 确保您具有适当的DNS记录:_ dkim _ spf _ dmarc

Make sure that reverse dns is setup and that the ip is not in a blocked pool, 确保设置了反向DNS,并且该IP不在阻塞池中,

Also, make sure you are not on any block list. 另外,请确保您不在任何阻止列表中。

IP reputations matter and get improved over time. IP信誉至关重要,并且会随着时间的推移而不断提高。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM