Chapter 15. Mail and Notifications
Sending an application’s users notifications via email, Slack, SMS, or another notification system is a common but surprisingly complex requirement. Laravel’s mail and notification features provide consistent APIs that abstract away the need to pay too close attention to any particular provider. Just like in Chapter 14, you’ll write your code once and choose at the configuration level which provider you’ll use to send your email or notifications.
Laravel’s mail functionality is a convenience layer on top of Symfony Mailer. Out of the box, Laravel comes with drivers for SMTP, Mailgun, Postmark, Amazon SES, Sendmail, and Log.
For all of the cloud services, you’ll set your authentication information in config/services.php. However, if you take a look, you’ll see there are already keys
there—and in config/mail.php—that allow you to customize your application’s mail functionality in .env using variables like MAIL_MAILER
and MAILGUN_SECRET
.
Get Laravel: Up & Running, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.