PHP 群发邮件:一人一份还是所有人一份?
使用 PHP 发送群发邮件时,最好向每个订阅者发送一封电子邮件(对所有电子邮件地址运行 for 循环),还是将所有内容以密件抄送方式添加到逗号分隔列表中,从而仅发送一封电子邮件?
谢谢。
When sending mass mails with PHP, is it better to send each subscriber an e-mail (running a for loop through all the e-mail addresses) or is it better to just add all in BCC in a comma separated list and thus sending only one e-mail?
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
SMTP 服务器上的 BCC 字段中的地址数量很可能受到限制(以避免垃圾邮件)。我会选择安全的路线并向每个订阅者发送一封电子邮件。如果需要,您还可以为每个订阅者自定义电子邮件。
另请注意,mail() 可能不是发送批量邮件的最佳方式(因为它每次调用时都会打开一个到 SMTP 服务器的新连接)。您可能需要查看 PEAR::Mail。
There's a good chance the number of addresses in the BCC field is limited on the SMTP server (to avoid spamming). I'd go with the safe route and send an e-mail to each individual subscriber. That will also allow you to customize the e-mail for each subscriber if needed.
Also note that mail() is probably not the best way to send bulk mail (due to the fact that it opens a new connection to the SMTP server each time it's invoked). You may want to look into PEAR::Mail.
最佳做法是向每个收件人发送一封电子邮件。
如果它是一个 Linux 邮件服务器,它可以处理大量的吞吐量,所以容量不应该成为问题,除非它是一个垃圾服务器!
如果它是共享网络服务器,您的主机可能会不高兴 - 如果是这种情况,我会将其分成块并分散发送。如果它是专用的,那么就按照你的意愿去做:)
Best practice is to send an email per recipient.
If it's a linux mail server, it can handle massive throughputs so volume should not be an issue unless it's a crap server!
If it's a shared webserver your host may not be happy - if this si the case I'd split it into chuncks and spread the send. If it's dedicated then do as you will :)
如果密件抄送收件人之一的发送过程因某种原因失败(例如可能导致无法解析的域),则整个操作将被取消(在 99% 的情况下这是不需要的行为)。
如果您在 PHP 循环中发送电子邮件,即使其中一封电子邮件发送失败,其他电子邮件也会发送。
If the sending process for some reason failed (example cause might me unresolvable domain) for one of the BCC recipients, the whole operation would be canceled (which is in 99% of cases unwanted behavior).
I you send the emails in a PHP loop, even if one of the emails fails to send, other emails will be sent.
正如其他人所说,每个收件人一封邮件更合适。
如果您希望库为您完成肮脏的工作,请尝试 SwiftMailer http://swiftmailer.org
这里是直接来自文档的示例:
它还有一个不错的 Antiflood 插件: http://swiftmailer.org/文档/antiflood-plugin-howto
As the others says one mail per recipient is the better fit.
If you want a library to do the dirty job for you, give a try to SwiftMailer http://swiftmailer.org
Here is an example directly from the docs:
It also has a nice Antiflood plugin: http://swiftmailer.org/docs/antiflood-plugin-howto