Implementing and executing cron jobs
The main usage of console applications consists in the execution of periodic tasks using cron job (on Linux or Unix machines).
We can use console applications to send massive e-mails to perform system maintenance or to check a specific status of the application.
In the next example, we will see how to send an e-mail with a summary of the reservations made in the current date.
Example – sending an e-mail with new reservations of the day
This example illustrates how to send an e-mail with a summary of new daily reservations.
First of all, let's configure the mailer
component in console/config/main.php
, if it is not already configured.
It is enough to pass a few parameters to the component:
'components' => [ .. .. 'mailer' => [ 'class' => 'yii\swiftmailer\Mailer', 'viewPath' => '@common/mail', // send all mails to a file...