Limit e-mail flow in Laravel

好久不见. 提交于 2019-12-11 02:27:43

问题


I'm working on an app built with Laravel 4.2.

My app will send a pretty large amount of individual emails. The problem is that my SMTP server has a limit of max 300 mails/30 minutes and 5000 mails/day

That will be enough for me. But I would want to control the flow of sen email by queuing them up to be sent at a rate of max 300 mails/30 mins.

Is there a simple way of doing that, using Laravels libraries?


回答1:


You're on the right track with the queue. Say you had a DB table with one row for each email to be sent, and a column tracking if that email has been sent. You could create a Laravel Command that would be executed as a cronjob every 30 minutes that would send the next 300 emails that have not yet been sent.

A better, cleaner and all around more scaleable option would be to implement one of the many queue engines supported by Laravel's Queues. This will require modification of the server environment much like installing mysql to support the database.



来源:https://stackoverflow.com/questions/30568069/limit-e-mail-flow-in-laravel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!