Question

In Laravel (for the record I'm using v5.6) there is an option to queue emails for background processing.

I have a scheduled job to send out daily email alerts to users. Currently the job drops the emails (mailables) in the Laravel database queue and I use the Mailgun driver for sending out emails.

My question is Mailgun automatically queues emails for delivery according to their docs (https://documentation.mailgun.com/en/latest/user_manual.html#message-queue)

So is there any benefit to me queuing these emails using the Laravel queue and having a queue worker process them only to be sent to another queue i.e. the Mailgun queue?

Any guidance and advice would be much appreciated on the correct process to sending these emails?

Was it helpful?

Solution

Update: Originally I wrote this answer recommending a queue on your side, but I had thought this other queue was also on your servers, inside your network. I just realized Mailgun appears to be an e-mail provider you have no control over (I have never used them or heard of them) and I've rewritten my answer accordingly.


When interacting with an external service your organization does not have direct control over, having a queue to add e-mails to another queue is a good idea.

Mailgun can go down. It can experience slowness. The network between your servers and theirs could become slow or unstable — or completely unusable if a construction worker in some other city between your servers and Mailgun's gets a little careless with a back hoe, and digs up a fiber optic cable.

Due to this risk of failure, I would highly recommend keeping your own queue. It allows you to retry operations on this external service provider in case you encounter problems, and it prevents those problems from leaking into your web application.

Licensed under: CC-BY-SA with attribution
scroll top