lundi 2 octobre 2017

Laravel Email Periodical Sending with Commands + Cron

I have a CMS built upon Laravel 5.4. Admins in this system should be able to create an Email blast and schedule it to send at a date and time they choose and at any custom interval they choose.

For example, a user creates Email 1 and Email 2. Email 1 should send tonight at 8 p.m. and then daily for the next week at 7 p.m. Email 2 should send next week at 3 p.m. and then monthly for six months.

I have created a command using

php artisan make:command SendEmails --command=emails:send

Within the SendEmail class, I have added the email parameter so that the command knows which email to send out:

protected $signature = 'todayemails:send {email}';

I have this part working when I run...

php artisan emails:send 1

But I can't seem to come across anything (if it's even possible) documenting how to set a cron for each email when it is created by the user. To complicate things, a user should be able to edit their time and frequency settings whenever they want.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire