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 matlab答疑 关于海上风电的爬坡事件检测
  • ¥88 python部署量化回测异常问题
  • ¥30 酬劳2w元求合作写文章
  • ¥15 在现有系统基础上增加功能
  • ¥15 远程桌面文档内容复制粘贴,格式会变化
  • ¥15 关于#java#的问题:找一份能快速看完mooc视频的代码
  • ¥15 这种微信登录授权 谁可以做啊
  • ¥15 请问我该如何添加自己的数据去运行蚁群算法代码
  • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”
  • ¥15 网络设备配置与管理这个该怎么弄