PHP: mail() vs SendMail

冷暖自知 提交于 2019-12-23 07:10:06

问题


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

mail() function or sendmail

which one is used by popular PHP list manager packages?


回答1:


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::Mail it allows you to use 3 backends: mail, sendmail and plain SMTP. For what it's worth, I've personally preferred SMTP because it's easy to support on both Linux and Windows.

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




回答2:


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.




回答3:


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

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.

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



来源:https://stackoverflow.com/questions/1883615/php-mail-vs-sendmail

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!