使用php邮件功能有限制吗?

发布于 2024-08-06 17:39:43 字数 491 浏览 5 评论 0原文

我正在使用 php 和 mysql。

我将发送 10k++(一万多)封电子邮件来更新我的订阅者,这是我第一次发送它们。我将使用 php 邮件功能,基本上这是我要做的:

首先从数据库获取数据:

Select name, email FROM data

之后,使用 while 循环发送数据:

while($r = mysql_fetch_assoc($exe)){
    ...
    if($mail){
        echo "success<br>";
    } else {
        echo "failed<br>";
    }
}
echo "Sent all";

我包括 if.. else 语句,以确保每封电子邮件均发送成功。有什么需要我照顾的吗?发送给 10K++ 用户时会遇到任何问题吗?

您要发送的电子邮件数量有限制吗?

I am using php and mysql.

I am going to send 10k++ (ten thousands plus) emails to update my subscribers, and this is the first time I am going to send them. I will use php mail function, basically here is what I will do:

First get the data from database:

Select name, email FROM data

After that, using while loop to send the data:

while($r = mysql_fetch_assoc($exe)){
    ...
    if($mail){
        echo "success<br>";
    } else {
        echo "failed<br>";
    }
}
echo "Sent all";

I include the if.. else statement, to ensure that each email is sent successfully. Is there anything I need to take care of? Will I have any problems when SENDING TO 10K++ users?

Is there a limit of numbers of emails that you are going to sent?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

剩余の解释 2024-08-13 17:39:43

请注意邮件文档中的此注释:

注意:值得注意的是,mail() 函数不适合循环发送大量电子邮件。该函数为每封电子邮件打开和关闭一个 SMTP 套接字,效率不是很高。
对于发送大量电子邮件,请参阅 » PEAR::Mail 和 » PEAR::Mail_Queue 包。

Please be aware of this note from the mail documentation:

Note: It is worth noting that the mail() function is not suitable for larger volumes of email in a loop. This function opens and closes an SMTP socket for each email, which is not very efficient.
For the sending of large amounts of email, see the » PEAR::Mail, and » PEAR::Mail_Queue packages.

看透却不说透 2024-08-13 17:39:43

邮件数量没有限制,但是PHP脚本有时间限制。请参阅 php 中设置的 max_execution_time .ini,通常为 20 或 30 秒。如果您不知道,请使用 phpinfo() 来查找。

此外,您应该采取一些措施来防止用户收到过多的电子邮件。您应该将它们标记为已发送,这样如果您不小心启动脚本两次,它们就不会收到重复的帖子。

除此之外,您应该注意,php 的邮件功能本质上根本没有优化。您可以尝试一些库,例如 phpmimemessage 或任何其他库,它们允许您进行一些缓存,例如,以及许多其他功能。

No limit to the emails number, but there is the time limit of the PHP script. See the max_execution_time set in your php.ini, typically it's 20 or 30 seconds. If you don't know that, use phpinfo() to find it out.

Moreover, you should take some steps to prevent users from getting too much emails. You should mark them as sent, so they don't receive double posts if you accidentally start the script twice.

Other than that, you should note that php's mail function is inherently not optimized at all. You could try some libraries, like phpmimemessage or any other, which will allow you do to some caching, for example, among many other features.

我为君王 2024-08-13 17:39:43

您应该建立一个已发送/失败的电子邮件队列,以便您可以尝试重新发送失败的尝试,并避免在出现问题时重新发送电子邮件。

不要创建一个尝试通过 mail() 发送 10k 封电子邮件的循环。

此外,您最有可能遇到的限制是 ISP 或主机的邮件服务器的限制。

You should build a queue of emails sent/failed, so you can try to resend failed attempts and avoid re-sending emails if something should go wrong.

Do not create a loop that tries to send 10k emails via mail()

Also, the most likely limit you'll hit will be that of the mail server of your ISP or host.

梦年海沫深 2024-08-13 17:39:43

您可能还想考虑设置一个“真正的”邮件列表工具,例如 mailman ,或者至少使用别名组(如果可能)。

另请参阅有关 serverfault 的相关问题: https://serverfault .com/questions/67154/sending-an-email-to-about-10k-users-not-spam,其中 PHPlist 与其他内容一起被提及。在这里 - https://serverfault.com/questions/68357/whats -发送批量电子邮件的最佳方式

You may also want to look at setting up a "real" mailing list tool, such as mailman, or at least using alias groups (if possible).

Also, see the related questions on serverfault: https://serverfault.com/questions/67154/sending-an-email-to-about-10k-users-not-spam, where PHPlist is mentioned, along with others. And here - https://serverfault.com/questions/68357/whats-the-best-way-to-send-bulk-email.

笑叹一世浮沉 2024-08-13 17:39:43

您可以使用 pear::Mail_Queue http://pear.php.net/package/Mail_Queue/

它确实会做得很好。

You can use pear::Mail_Queue http://pear.php.net/package/Mail_Queue/

It will really do a good job.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文