dongyuchen0214 2013-04-19 06:41
浏览 68
已采纳

通过Amazon Simple Mail Service向用户发送批量邮件

In one of my web application I have to send email to my users ( all mails are transnational, user accept privacy policy and terms ans conditions).

Currently Amazon grand me to send 10000 emails per 24 hours and we can easily increase the quota. My question is we can only send 5 emails per second via amazon. So I am bit confused with the PHP script ( loop ) to handle the same. A normal PHP loop can handle this bulk emails ?

Is there any delay in while loop is available ? So that we can limit it 2-3 emails per second. Since the script is working in a cron job

Thanks in advance

  • 写回答

2条回答 默认 最新

  • dsp1836 2013-04-19 21:10
    关注

    This will require a little bit of code, but not much, but if you separate the task that generates emails, from the task that actually does the emailing, you could use amazon SQS and a cron job to do the mailing.

    What I do is I have an SQS queue called 'EmailQueue', that contains the "TO", "Subject" and body of the email in the message. The job the generates the emails to be sent simply places all of these messages into a queue, as fast as it can/wants to.

    I then have a scheduled task that runs every minute that goes to the queue and downloads a set number of emails to go out depending on the throttle in place. The cron job builds and sends the email message from the information stored in the SQS messages and deletes the message(s) as they are sent - it doesn't need access to anything else since everything required to send the email is encapsulated in the SQS message.

    You control the throttle by the timing of the cron job. In my case, my job will only process up to 5 emails on each run before it exits.

    Using a queue and a cron job also removes any delay that might exist for the UI user (assuming there is one), since the loading of the messages into the queue is fast, and SMTP emailing is sometimes slow it can cause a noticeable lag to the end user.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测