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

rvanbaalen's avatar

Best way to schedule trial end notifications

Hi,

I was wondering which method you guys would recommend for scheduling email notifications to users of which the trial is about to expire.

Trial duration: 14 days. First notification: 3 days left (on day 11) second notification will be on day 14.

Now I noticed there are two ways to send an email with Laravel 5.4. One way would be to create a new Notification (email notification) and schedule it for over 11 days when the user is created. At the same time the expired notification (email) can be pushed to the same queue to be sent in 14 days from now. This method would require a functioning queue and I'm wondering what could go wrong? What if my queue crashes for some reason? Will these scheduled notifications be lost?

The other method is a bit more straightforward: create a scheduled script that runs every night looking for Users whos trials are about to expire and push an email notification to the queue for later that day (say, 9am).

This would allow for shorter queues (and less risk of queue loss?)

Which method would you recommend and/or is there a third (better) way to do this?

Before everyone starts to dive into Cashier; I can't use it since it's tightly coupled to Stripe unfortunately. (I'd like to see Cashier functions without the tight Stripe logic built in.. but that's for another topic).

0 likes
4 replies
mikefolsom's avatar
Level 21

If you use scheduled artisan commands, there is no need to queue the notifications (there is no HTTP request being held up waiting for the mail to send). Simply run the scheduled tasks every day (i.e. at 6 AM), build your collections based on current criteria, and use the Notification::send() facade.

So one command might be SendFirstTrialEndingNotifications and another SendSecondTrialEndingNotifications.

See https://laravel.com/docs/master/notifications#using-the-notification-facade and https://laravel.com/docs/master/scheduling

mikefolsom's avatar

@rvanbaalen Seems the most direct method and the one I would use personally. Queues are meant to speed up HTTP requests by allowing time-consuming tasks to run asynchronously. They are not intended to be delayed for for more than a few minutes (if at all). So I don't see a need to push to a queue at all in this case.

1 like
Cheers02's avatar

@rvanbaalen how u call your notification in your kernel.php?? in my case i want to send this email notification everyday

Please or to participate in this conversation.