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

sandstorm's avatar

sending email after specific date

hello guys i want to prepare an email to be sent after 50 days when the user click on a button then go to controller i found "later" method but i did not work, its sends the email immediately. also i found "scheduler" but i could not understand how to work with it because its about every day , monthly, yearly,... what i want is after specific date only may laravel is 5.2

0 likes
12 replies
jekinney's avatar

The scheduler fires when ever you need it. Probably in your case every day. Then the scheduler fires a command. In the command you can query and get any users That clicked the button 50 days or more where you haven't sent an email yet (assuming you store that data somewhere). After email successfully sent, mark the data row (update Boolean value) so you don't send again.

Scheduler is based off a single cron job. A nice wrapper to schedule tasks.

3 likes
willvincent's avatar

@jekinney's suggestion makes a lot more sense than shoving it into a queue to wait 50 days. Store the necessary information in the database, and check that table daily for any items that are now 50 days old, and process them, at which point you could either remove them or mark them as processed with a date stamp/etc.

Using a redis or similar queue, for this particular use case seems entirely wrong to me.

1 like
sandstorm's avatar

@willvincent do you mean i use the method daily in Scheduler then i make if condition if that date more than 50 days, the function sends the email?

willvincent's avatar

@sandstorm as @jekinney suggested, yes I think that makes the most sense in your case given the length of the delay you're looking for before taking action.

1 like
martinbean's avatar

@sandstorm As suggested by @jekinney, the best approach (and the one that immediately sprung to mind to me) was to set up a scheduler task that runs every day and each day it runs, you check for users who “clicked a button” 50 days ago and send them the email.

1 like
sandstorm's avatar

thanx all of you guys @jekinney @bobbybouwmann @willvincent @martinbean problems never ends. now i try to set up scheduler

i try this command

          • php /path/to/artisan schedule:run >> /dev/null 2>&1 the error is The system cannot find the path specified.

i try to type in cmd "crontab -e" the error is 'crontab' is not recognized as an internal or external command, operable program or batch file.

willvincent's avatar

Are you working in a windows environment? It doesn't have cron.

1 like
sandstorm's avatar

yes i work in windows 10 if so, there is no other why?

vmitchell85's avatar

@sandstorm you'll need to change the path.

php /path/to/artisan the path to artisan is the path to the directory your application is in... so it might be something like php /var/www/myapp/artisan

sandstorm's avatar

@vmitchell85 i change it this way C:>* * * * * php /xampp/htdocs/training-portal/artisan schedule:run >> /dev/null 2>&1 The system cannot find the path specified.

as you see still have problem

is it correct path? my actual path is C:\xampp\htdocs\training-portal

sharjeel's avatar

Windows do not support Cron Jobs, you have to either create a schedule task in windows or switch to linux environment.

Please or to participate in this conversation.