Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

AbehoM's avatar

What is the best way to queue emails

I'm creating a website that will need to send a lot of e-mails because it has a built in subscription system, so I need to send the user verification e-mail, payment confirmation, billing e-mail, and things like that so I thought about queuing them, what would be the best way? My subscription system is using events, every time something happens I fire an event, for example: SubscriptionRenewed, SubscriptionCreated, SubscriptionCanceled. I need to send e-mails based on those events but queued so it doesn't slow the server.

0 likes
4 replies
bobbybouwmann's avatar

Well just create a listener that queues a new email for you. So that can be a queue job for example or a queuable mailable. This way you should be good to go.

You seem to know the right terms, so just create a queue and start sending emails ;)

AbehoM's avatar

You are right, just need to verify if I need only one listener for all the events or multiple listeners, I will checking it out. Thank you.

bobbybouwmann's avatar
Level 88

Yeah so I would split every action in a separate listener. This way you might be able to reuse them. Also keeping your classes small makes them more testable and readable ;)

Please or to participate in this conversation.