Bartude's avatar

Queue Jobs and Mail Notifications

Hey guys,

I have 15 notifications of which each are executed depending on the user's action. Each one has a different body and a varied number of parameters being passed to the __constructor.

Since each notification takes some seconds to actually send the email, I want to put them in a queue.

The only way I can think of is to create 15 different Jobs files. My question is, is there a better way to do this? Or am I just overthinking and this is the best way?

0 likes
3 replies
EventFellows's avatar

at some point you have to have 15 versions but it does not need to be the jobs where that happens.

you can also send one of the 15 different emails from one job based on some conditions.

you can also queue mails directly without using a job at all. same is true for a setup with events and listeners.

and even further: you can use the same email for similar notifications with conditionals within that email. but this only makes sense if emails are very similar in my opinion.

Bartude's avatar

@EventFellows You're right, actually some of the notifications have to happen on the Scheduler.

But how can I queue mails directly without using a job? (When you say mails, I assume you mean mails by notification) This is what I've tried: dispatch($company_user->notify(new CompanyAdScheduled($ad, $request->date, $request->time, $company_name->companyName)));

And it gives this error: ReflectionException in Container.php line 553: The parameter class is expected to be either a string or an object

Please or to participate in this conversation.