How can I send no more than 1000 emails per hour on Laravel with Mail and Queue? Thank you in advance!
Asked
Active
Viewed 1,104 times
2
-
You need to use queue driver/server (e.g. beanstalkd), use Mail::queue() instead of Mail::send() and then run a cron job "php artisan queue:work" – Michail Strokin Jan 27 '16 at 18:42
-
You can read about it here: http://laravelcoding.com/blog/laravel-5-beauty-sending-mail-and-using-queues#14-queue-drivers – Michail Strokin Jan 27 '16 at 18:51
-
1@MichailStrokin I'm already using the Database driver, with the Mail::queue, but I want to know how can I set a limit per hour of how much jobs the queue runs. – Eduardo Macêdo Jan 27 '16 at 19:28
-
3there's no magic methods for doing that AFAIK, probably easiest way to do that is to create a job which sends the messages, then fetch the number of processed jobs in last hour inside that job, and then 'release' the job if it's more than 1000 (using something like $this->release(10);) – Michail Strokin Jan 27 '16 at 20:57
-
@MichailStrokin thanks, I'll do that! – Eduardo Macêdo Jan 27 '16 at 21:15
-
Maybe there is some way to use `Swift_Plugins_ThrottlerPlugin` (like https://stackoverflow.com/a/53783301/470749) within `SendQueuedMailable`? – Ryan Dec 14 '18 at 16:20