Setting up e-mail notices
In this recipe, we are going to use the previous work to trigger an event that will send e-mails. E-mails are a slow process sometimes, so I will put them in a queue. In this case, it will be a database queue since it is just local communication. Once we are done, we will see how to send a "nice" looking e-mail.
Getting ready
A base Laravel install will do. I will be working from the previous work, but you can follow along.
How to do it…
First, let's make our queue database tables:
> php artisan queue:table && php artisan migrate
Then, let's set this to sync in our
.env
file. Make sure that theQUEUE_DRIVER
variable in your.env
file looks like the example here:In the
.enf
file, we will setMAIL
to log until we are ready:Then, we will make the job:
> php artisan make:job SendFavoritesEmail
Let's just add a placeholder there for now, it is
app/Jobs/SendFavoritesE-mail.php
:Now, our handler will react to the queue, which I will...