Company
Date Published
Author
Michael Okoko
Word count
1233
Language
English
Hacker News points
None

Summary

SendGrid` is a popular email service provider used to send emails programmatically. The Laravel Task Scheduler allows developers to define tasks as code, leveraging the framework's logging and error handling features. In this tutorial, we will use `SendGrid` to send daily reports of new signups on a Laravel application. To achieve this, we need to create a recurring task that sends an email to the administrator with the number of new users each day. The task is defined as an invokable object and uses the `Carbon` library to calculate the percentage difference between the previous day's and today's user count. The email is sent using the `SendGrid` API, which requires an API key to be set up in the `.env` file. The Laravel Task Scheduler is then used to schedule the task to run daily at 11:59 PM and append the output to a log file.