电子邮件帮助 - php mail() 或 SMTP
我有一个时事通讯脚本,它循环遍历成员并向每个成员单独发送一封邮件。以前运行正常,但随着数量的增加,脚本开始崩溃。我正在使用 SwiftMailer,收到的消息是“使用 mail() 作为 PHP 的默认 mail() 发送失败”。尝试使用 SMTP 而不是本机 mail() 函数发送会有什么好处吗?或者我应该寻找另一个解决方案。感谢您的指点。
I have a newsletter script which loops through members and sends a mail to each individually. this was running ok previously, but as the numbers have increased, the script has started to crash part way through. I'm using SwiftMailer and the message I'm getting is "sending failed using mail() as PHP's default mail()". Would there be any benefit to trying to send with SMTP instead of the native mail() function? Or should I be looking at another solution. Thanks for any pointers.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
实际上,
mail()
函数并不发送邮件。它只是将您生成的邮件移交给系统的 SMTP 服务器。无论哪种方式,您都将使用 SMTP。如果 swiftmailer 使用 PHP 的 mail() 函数,那么很可能您系统的 SMTP 设置出了问题。检查系统日志(特别是邮件日志)以获取线索,并查看 Swiftmailer 是否会为您提供更好的错误消息。
The
mail()
function doesn't deliver mail, actually. It just hands over the mail you generated to the system's SMTP server. Either way, you're going to be using SMTP.If swiftmailer is using PHP's mail() function, then most likely something's gone screwy with your system's SMTP setup. Check system logs (the maillog in particular) for clues, and see if Swiftmailer will give you any better error messages.
根据 开发 Swiftmail 的聪明人的建议并可能在这些问题上碰头(为了避免你和我做同样的事情),它可能会帮助你使用 SMTP 而不是
mail
传输此外,在同一页面上,他还解释了如何通过简单地迭代“to”字段来处理新闻通讯,而不是阅读同一页面上的批量发送电子邮件部分
According to the suggestions of the smart guy who developed Swiftmail and proabably banged his head on these issues (in order to avoid you and me to do the same), it might help you to use SMTP and not
mail
transportMoreover on the same page he also explains how to handle newsletters by simply iterating over the to field instead read section Sending Emails in Batch on the same page
mail()
函数使用 SMTP 发送电子邮件。不过,您可能想尝试类似PEAR::Mail
的东西。使用mail()
将为每封邮件打开一个新的 SMTP 连接,这在循环内执行效率相当低。这很可能会导致您的错误,尽管对于这样一个通用的错误消息,如果不进行更多挖掘就不可能确定。The
mail()
function sends email with SMTP. You might want to try something likePEAR::Mail
, however. Usingmail()
will open a new SMTP connection for each message, which is fairly inefficient to do inside a loop. This may very well be causing your errors, although with such a generic error message it's impossible to be sure without more digging.