PHP:mail() 与 SendMail

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1883615/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 04:10:29  来源:igfitidea点击:

PHP: mail() vs SendMail

phpemailwebserver

提问by ankitjaininfo

a simple question: which one has good performance for sending mails in bulk?

一个简单的问题:哪一个具有良好的批量发送邮件的性能?

mail()function or sendmail

mail()函数或sendmail

which one is used by popular PHP list manager packages?

流行的 PHP 列表管理器包使用哪一个?

采纳答案by Percutio

Well the mail()function is not really suitable for emails sent in bulk because it opens and closes an SMTP socket for each email you send, which is far from being efficient. If you look at PEAR::Mailit allows you to use 3 backends: mail, sendmailand plain SMTP. For what it's worth, I've personally preferred SMTP because it's easy to support on both Linux and Windows.

好吧,该mail()功能并不真正适合批量发送的电子邮件,因为它会为您发送的每封电子邮件打开和关闭一个 SMTP 套接字,这远非有效。如果你看一下PEAR ::邮件它允许你使用3个后端:mailsendmail朴素SMTP。就其价值而言,我个人更喜欢 SMTP,因为它在 Linux 和 Windows 上都易于支持。

If you wish to send mails in the background using a queue, PEAR::Mail_Queuemight be a solution.

如果您希望使用队列在后台发送邮件,PEAR::Mail_Queue可能是一个解决方案。

回答by Jordan Ryan Moore

sendmail is a Mail Transfer Agent (MTA). On UNIX and Linux based systems, PHP's mail()function simply relays the email though sendmail (or a compatible MTA). For sending bulk email, you may want to look into directly connecting to an SMTP server. Zend Framework provides an SMTP transport.

sendmail 是邮件传输代理 (MTA)。在基于 UNIX 和 Linux 的系统上,PHP 的mail()功能只是通过 sendmail(或兼容的 MTA)中继电子邮件。要发送批量电子邮件,您可能需要考虑直接连接到 SMTP 服务器。Zend Framework 提供了SMTP 传输

回答by Byron Whitlock

If you are running the SMTP mail server yourself, make sure you have SPFand domain keysset up properly or your mail will end up in the junk box for most large domains (yahoo, gmail etc).

如果您自己运行 SMTP 邮件服务器,请确保您正确设置了SPF域密钥,否则您的邮件将最终出现在大多数大型域(雅虎、gmail 等)的垃圾箱中。

Also don't forget about bounce handling and robust unsubscribe functionality. Without those your email blasts will be much less effective, and your IP will get blacklisted.

也不要忘记退回处理和强大的取消订阅功能。没有这些,您的电子邮件群发效率将大大降低,您的 IP 将被列入黑名单

And of course don't allow open relays. Do your homework and tread with caution, spammers have made it difficult for us.

当然也不允许开放中继。做好功课并谨慎行事,垃圾邮件发送者给我们带来了困难。