简体   繁体   English

从数据库发送电子邮件

[英]Send e-mails from DB

I have a MySQL database in which I hold the mail adress from all the users on my website. 我有一个MySQL数据库,其中保存着我网站上所有用户的邮件地址。 How can I send an e-mail to each of them? 如何向他们每个人发送电子邮件?

I guess PHP is a little slow. 我猜PHP有点慢。 I've tried a CGI script but it failed (it sent some e-mails then it got stuck xD). 我尝试了CGI脚本,但失败了(它发送了一些电子邮件,然后卡在xD上)。

Is there an "usuable" PHP only solution? 是否有“仅适用于” PHP的解决方案? I only have like 300users atm, but I want the script to work for like 10.000 users. 我只有300个用户的atm,但是我希望该脚本能为10.000个用户工作。

I've heard about SwiftMailer (or something like that) but I want to know if I can create my own script that can work. 我听说过SwiftMailer(或类似的东西),但是我想知道我是否可以创建自己的脚本。

Don't recreate the wheel. 不要重新创建轮子。 SwiftMailer is easy to use, extensible, and very customizable. SwiftMailer易于使用,可扩展且非常可定制。 It also has considerations for throttling and antiflooding. 它还考虑了节流和防洪问题。

If it's a timeout issue (mail() function is really slow) I usually use ajax to have the server do a small slice (say 10 rows) at a time. 如果是超时问题(mail()函数确实很慢),我通常使用ajax让服务器一次做一小片(比如说10行)。 That also gives you feedback about how far along it is in processing the whole file. 这还会为您提供有关处理整个文件的进度的反馈。 Each subsequent ajax call tells the server what line to start on, it does 10 sends back a success/fail to the browser/javascript, which sends another ajax request to do another 10, repeat. 随后的每个ajax调用都会告诉服务器要从哪一行开始,它执行10,将成功/失败发送回浏览器/ javascript,浏览器/ javascript发送另一个ajax请求以执行另外10次,重复一次。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM