问题描述
我想发送一些使用php的批量电子邮件。过去我已经做了一个foreach循环,我使用php mail()函数。但是,当有很多电子邮件发送出去时,通常会备份并崩溃服务器。不要使用 mail()
大容量电子邮件发送功能。 (我认为这在手册中甚至说明了)。该函数打开一个新的smtp连接每个邮件,这是非常无效的。更好地使用SMTP客户端,可以为所有电子邮件重复使用相同的连接。
您将在google上找到很多图书馆。对于我来说,是一个整体的MTA,这可能是有趣的,因为你可以做很多更准确的统计数据。如果你不喜欢试验,可以随时使用PEAR课程,是您需要的。
编辑:只需检查手册。有一个大量电子邮件的说明:
I want to send out some batch e-mails using php. I have done so in the past with a foreach loop within which I use the php mail() function. However, when there are a lot of e-mails to send out, this often gets backed up and crashes the server. How can I do this without overwhelming the system?
Don't use the mail()
function for mass e-mail sending. (I think it's even stated in the manual.) The function opens a new smtp connection per mail, which is highly ineffective. Better use an SMTP client, which can reuse the same connection for all your emails.
You'll find lots of libraries on google. The first result for me is a whole MTA, which might be interesting, because you can do much more accurate stats with that. If you're not feeling like experimenting, you can always use PEAR classes, Mail is what you need.
Edit: Just checked the manual. There's a note on mass e-mailing:
这篇关于如何使用php mail()函数而不破坏服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!