2

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?

Christoffer
  • 7,470
  • 9
  • 39
  • 55
  • I found this article interesting: https://www.camroncade.com/limit-the-number-of-messages-sent-on-one-smtp-connection-laravel-5/ – Ryan Dec 11 '18 at 20:54
  • The same question is over here, and I just answered it: https://stackoverflow.com/a/53783301/470749 – Ryan Dec 14 '18 at 16:13

1 Answers1

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.

Collin James
  • 9,062
  • 2
  • 28
  • 36