PHP邮件函数不发送电子邮件到特定地址

时间:2022-10-23 18:04:05

I've been using the php mail function to send emails containing account details to clients when they are registered but I have only just found out that some people are not receiving emails. E.g. when I send an email to each of my collegues when testing only me and one other collegue are receiving the email

我一直在使用php邮件功能向客户发送包含帐户细节的邮件,但我刚刚发现有些人没有收到邮件。当我给我的每个同事发电子邮件时,只有我和其他同事收到了电子邮件

- me who received email
- pam@companyx.co.uk
- collegue who received email
- bill@companyx.co.uk
- collegue who did not receive emails:
- email 1 - ted@companyx.co.uk,
- email 2 - ted@companyy.co.uk
- collegue who did not receive emails:
- cal@companyy.co.uk
- collegue who did not receive emails:
- emma@companyy.co.uk

The emails are not received in the spam folder either..

垃圾邮件文件夹里也没有收到这些邮件。

$from = "companyy <support@companyy.co.uk>";          
$subject = "$username Account Details for companyy.co.uk";     
$message = "You have been registered as an administrator of companyy Online.
You can manage your clients, bills and other account functions online.       

Your Username: $username
Your Password: $password2
Your Four-Digit PIN: $PIN         

Once logged in you can change your password to something you will find easier to remember. Please delete this email once you have changed your settings or memorised them.           

Thank you        

This is an automated response, please do not reply!";

mail($email, $subject, $message, $from);
Header('Location: results.php?msg=Added Successfully');

5 个解决方案

#1


7  

Here's a dirty little secret about sending emails: you lose control. Once they've left your server, it's by the grace of the internet gods that your email reaches its destination. Along the way it "handshakes" from one network to the next. It reaches its final destination and then is subjected to multitudes of spam filters and rules that many technical people are in the dark on. For instance, did you know that MSN Hotmail, AOL, etc will not accept more than a certain number of emails from a server (ip range) at once? Once you hit the server's predetermined (and unpublished) limit, the email will be held regardless of its spam rating. Eventually it will be let through, but it means that the password request your user does won't be instantaneous. Here's another tidbit--servers gain "trust" based on longevity of the domain and other factors that are also unpublished. Has your domain been live long? Are you listed on a blacklist? Is the email "spammy" (check with a tool like this)

关于发送电子邮件有一个肮脏的小秘密:你失去了控制。一旦他们离开了你的服务器,你的电子邮件就会以互联网之神的恩惠到达目的地。一路走来,它从一个网络“握手”到另一个网络。它到达了它的最终目的地,然后受到大量垃圾邮件过滤器和许多技术人员不知情的规则的影响。例如,你是否知道MSN Hotmail、AOL等不能同时接收超过一定数量的来自服务器(ip范围)的电子邮件?一旦您达到了服务器预定的(和未发布的)限制,不管它的垃圾邮件评级如何,邮件将被保存。最终它将被允许通过,但这意味着您的用户所做的密码请求不会是即时的。这是另一个有趣的地方——服务器获得“信任”是基于领域的寿命以及其他未发布的因素。你的域名是否长久?你被列入黑名单了吗?电子邮件是“垃圾邮件”吗?

Then there's sites like AOL where even good quality email from good quality servers just doesn't get delivered with regularity. (Google "aol deliverability" for some fun reading)

还有像美国在线这样的网站,即使质量好的服务器发出的高质量的邮件也不会有规律的交付。(谷歌“aol可交付性”,供大家阅读)

So, what to do? Start with blacklist checking. If that's good, check the headers. Does the "from" address match the domain the email's being sent from and is that account valid? That can be a big spam red-flag. To avoid this problem, my company (who sends 50,000+ emails per day) usually sets up "dummy" reply-to accounts. Are you in the whitelist for the users you're testing with? Are the users using a program like Outlook which randomly does its own blacklisting? Change your message and see if deliverability improves. Test with multiple different hosts to see if it's just one particular system.

那么,怎么做?从黑名单检查。如果这样很好,请检查标题。“from”地址是否与电子邮件发送的域匹配,该帐户是否有效?这可能是垃圾邮件的一大危险信号。为了避免这个问题,我的公司(每天发送5万封以上的邮件)通常会设置“虚拟”回复账户。您是否在您正在测试的用户的白名单中?用户是否使用像Outlook这样的程序,随机地进行自己的黑名单?改变你的信息,看看是否可以改进。使用多个不同的主机进行测试,看看它是否是一个特定的系统。

Rinse, repeat, and continue...

冲洗,重复,继续……

#2


0  

It appears that the emails are sent. The problems is on the receiving side. Check for spam or for filters. You can log the sent mails to be sure what was sent.

看来这些邮件是被发送的。问题在接收方。检查垃圾邮件或过滤器。您可以记录发送的邮件,以确定发送了什么。

#3


0  

You have to debug $email, maybe it's empty or bogus:

你必须调试$email,也许它是空的或者假的:

var_dump($email);

But this problem is probably not related to php. First of all check some email blacklist site, like http://www.mxtoolbox.com/blacklists.aspx

但是这个问题可能与php无关。首先查看一些黑名单网站,比如http://www.mxtoolbox.com/blacklists.aspx

If you can't find your box on any blacklist, you have to contact the server administrator, who have to check the out the logs.

如果您在任何黑名单上都找不到您的框,您必须联系服务器管理员,他们必须检查日志。

#4


0  

you may have an ip address that has been blacklisted, common in shared hosting. either move servers or outsource email to sendgrid or postmarkapp

您可能有一个被列入黑名单的ip地址,在共享主机中很常见。要么将服务器转移,要么将邮件外包给sendgrid或postmarkapp

#5


0  

Check your message and make sure it is seperated w/ PHP_EOL

检查你的信息,确保它是分开的w/ PHP_EOL。

Message to be sent.

要发送的消息。

Each line should be separated with a LF (\n). Lines should not be larger than 70 characters.

每一行应该用LF (\n)分隔。行不应该大于70个字符。

eg:

例如:

$message = 'This message was sent via PHP!' . PHP_EOL .
           'It should work ... and it does.' . PHP_EOL . PHP_EOL . 
           'From Display Name' . PHP_EOL;
// In case any of our lines are larger than 70 characters, we should use wordwrap()
$message = wordwrap($message, 70);

When using PHP mail

当使用PHP邮件

#1


7  

Here's a dirty little secret about sending emails: you lose control. Once they've left your server, it's by the grace of the internet gods that your email reaches its destination. Along the way it "handshakes" from one network to the next. It reaches its final destination and then is subjected to multitudes of spam filters and rules that many technical people are in the dark on. For instance, did you know that MSN Hotmail, AOL, etc will not accept more than a certain number of emails from a server (ip range) at once? Once you hit the server's predetermined (and unpublished) limit, the email will be held regardless of its spam rating. Eventually it will be let through, but it means that the password request your user does won't be instantaneous. Here's another tidbit--servers gain "trust" based on longevity of the domain and other factors that are also unpublished. Has your domain been live long? Are you listed on a blacklist? Is the email "spammy" (check with a tool like this)

关于发送电子邮件有一个肮脏的小秘密:你失去了控制。一旦他们离开了你的服务器,你的电子邮件就会以互联网之神的恩惠到达目的地。一路走来,它从一个网络“握手”到另一个网络。它到达了它的最终目的地,然后受到大量垃圾邮件过滤器和许多技术人员不知情的规则的影响。例如,你是否知道MSN Hotmail、AOL等不能同时接收超过一定数量的来自服务器(ip范围)的电子邮件?一旦您达到了服务器预定的(和未发布的)限制,不管它的垃圾邮件评级如何,邮件将被保存。最终它将被允许通过,但这意味着您的用户所做的密码请求不会是即时的。这是另一个有趣的地方——服务器获得“信任”是基于领域的寿命以及其他未发布的因素。你的域名是否长久?你被列入黑名单了吗?电子邮件是“垃圾邮件”吗?

Then there's sites like AOL where even good quality email from good quality servers just doesn't get delivered with regularity. (Google "aol deliverability" for some fun reading)

还有像美国在线这样的网站,即使质量好的服务器发出的高质量的邮件也不会有规律的交付。(谷歌“aol可交付性”,供大家阅读)

So, what to do? Start with blacklist checking. If that's good, check the headers. Does the "from" address match the domain the email's being sent from and is that account valid? That can be a big spam red-flag. To avoid this problem, my company (who sends 50,000+ emails per day) usually sets up "dummy" reply-to accounts. Are you in the whitelist for the users you're testing with? Are the users using a program like Outlook which randomly does its own blacklisting? Change your message and see if deliverability improves. Test with multiple different hosts to see if it's just one particular system.

那么,怎么做?从黑名单检查。如果这样很好,请检查标题。“from”地址是否与电子邮件发送的域匹配,该帐户是否有效?这可能是垃圾邮件的一大危险信号。为了避免这个问题,我的公司(每天发送5万封以上的邮件)通常会设置“虚拟”回复账户。您是否在您正在测试的用户的白名单中?用户是否使用像Outlook这样的程序,随机地进行自己的黑名单?改变你的信息,看看是否可以改进。使用多个不同的主机进行测试,看看它是否是一个特定的系统。

Rinse, repeat, and continue...

冲洗,重复,继续……

#2


0  

It appears that the emails are sent. The problems is on the receiving side. Check for spam or for filters. You can log the sent mails to be sure what was sent.

看来这些邮件是被发送的。问题在接收方。检查垃圾邮件或过滤器。您可以记录发送的邮件,以确定发送了什么。

#3


0  

You have to debug $email, maybe it's empty or bogus:

你必须调试$email,也许它是空的或者假的:

var_dump($email);

But this problem is probably not related to php. First of all check some email blacklist site, like http://www.mxtoolbox.com/blacklists.aspx

但是这个问题可能与php无关。首先查看一些黑名单网站,比如http://www.mxtoolbox.com/blacklists.aspx

If you can't find your box on any blacklist, you have to contact the server administrator, who have to check the out the logs.

如果您在任何黑名单上都找不到您的框,您必须联系服务器管理员,他们必须检查日志。

#4


0  

you may have an ip address that has been blacklisted, common in shared hosting. either move servers or outsource email to sendgrid or postmarkapp

您可能有一个被列入黑名单的ip地址,在共享主机中很常见。要么将服务器转移,要么将邮件外包给sendgrid或postmarkapp

#5


0  

Check your message and make sure it is seperated w/ PHP_EOL

检查你的信息,确保它是分开的w/ PHP_EOL。

Message to be sent.

要发送的消息。

Each line should be separated with a LF (\n). Lines should not be larger than 70 characters.

每一行应该用LF (\n)分隔。行不应该大于70个字符。

eg:

例如:

$message = 'This message was sent via PHP!' . PHP_EOL .
           'It should work ... and it does.' . PHP_EOL . PHP_EOL . 
           'From Display Name' . PHP_EOL;
// In case any of our lines are larger than 70 characters, we should use wordwrap()
$message = wordwrap($message, 70);

When using PHP mail

当使用PHP邮件