循环发送大量电子邮件
我有一个发送大量电子邮件报告的系统(每天大约 500 多封电子邮件)。我不是垃圾邮件发送者:) 这并不是大量的电子邮件,但它们是循环发送的,我经常收到此错误“PHP 警告:mail():无法执行邮件传递程序”。我知道有 PEAR::Mail_Queue 包解决这个问题。但是您能否让我知道该软件包是否真的有用,或者我是否需要寻找其他东西。多谢
I have a system that sends lots of emails reports ( about 500+ emails per day). I am not a spammer :) It's not really big amount of e-mails, but they are send in a loop and I often get this error "PHP Warning: mail(): Could not execute mail delivery program". I know there is PEAR::Mail_Queue package for this issue. But can you please let me know if that package is really useful thing, or do I need to look for something else. Thanks a lot
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以使用 PEAR 的 Mail_Queue 包 直接通过 SMTP 服务器发送邮件 - 它也可以工作在后台运行,因此不会延迟或增加脚本执行时间。
使用 Mail_Queue 包的另一个优点是,您可以检索出于日志记录目的发送的每封邮件的 esmtp id - 我不知道 Zeta Mail 组件或任何其他组件是否可以实现这一点。
我已经开发了许多面向公众且仅限内部网的解决方案,这些解决方案使用此组件并且没有遇到任何重大问题。
You can use PEAR's Mail_Queue package to send mails through an SMTP server directly - also it will work in the background and so won't delay or increase your script execution time.
Another advantage of using the Mail_Queue package is that you can retrieve the esmtp id of each mail sent for logging purposes - I don't know if this is possible with the Zeta Mail component or any other one.
I've developed a number of public-facing, and also intranet only, solutions that use this component and haven't had any major problems with it.
...这正是它在罐头上所说的意思。 PHP 只会将电子邮件传递给 Linux/Unix/POSIX 系统上的外部程序(由 php.ini 中的 sendmail_path 定义)。在某些情况下会返回错误。这不是 PHP 代码中的错误。
除非您的 MTA 配置非常错误,否则使用 SMTP 连接将无法解决该问题。
您需要查看 MTA 的日志以了解为何无法发送邮件,或者将邮件可执行文件包装在日志记录脚本中。
...means exactly what it says on the tin. PHP will just hand the email off to an external program on a Linux/Unix/POSIX system (as defined by sendmail_path in php.ini). And in some cases that is returning an error. It's not a fault within the PHP code.
Unless you've got a really badly configured MTA, then the problem will not be resolved by using an SMTP connection instead.
You need to look at the logs from your MTA to see why its failing to send the mail - or wrap the mail executable in a logging script.
你必须在邮件之间使用 sleep() 来解决这个问题。
You gotta use sleep() between mails, that solves this.
另一种方法是直接通过 SMTP 服务器发送邮件。这节省了 PHP“通过 shell”调用 sendmail(或任何使用的 MTA)来传递邮件的往返过程。例如,Zeta Mail 组件 允许您直接通过 SMTP 服务器发送邮件,而无需为此使用特殊扩展。
An alternative could also be to send mails through an SMTP server directly. This saves you the round trip of PHP calling sendmail (or whatever MTA is used) "through the shell" in order to deliver the mail. For example the Zeta Mail component allows you to send mails directly through an SMTP server without needing a special extension for this.