Integrating Resend: Modernizing the Laravel Email Stack
Overview
Sending email is a core requirement for almost every modern web application, but managing the underlying infrastructure can be a headache.
Prerequisites
To follow this guide, you should be comfortable with basic
Key Libraries & Tools
- ResendSDK: The core package that bridgesLaravelwith theResendAPI.
- Composer: The dependency manager used to install the necessary transport layers.
- Laravel Breeze: A starter kit used here to demonstrate real-world authentication emails.
Code Walkthrough
First, pull in the official transport package via
composer require resend/resend-php-laravel
Next, update your .env file to point to the new driver. You can strip out old SMTP settings like MAIL_HOST and MAIL_PASSWORD because
MAIL_MAILER=resend
RESEND_API_KEY=re_123456789
MAIL_FROM_ADDRESS="[email protected]"
For custom logic or quick alerts, you can use the
use Resend\Laravel\Facades\Resend;
Resend::emails()->send([
'from' => '[email protected]',
'to' => '[email protected]',
'subject' => 'System Update',
'html' => '<strong>Everything is running smoothly!</strong>',
]);
Syntax Notes
The integration utilizes Laravel Facades, providing a static-like interface to the underlying send method, which mirrors Mailable class.
Practical Examples
Beyond simple notifications, this setup is perfect for password resets and email verification. Because Auth notifications automatically route through MAIL_MAILER is set. You don't have to rewrite a single line of authentication logic.
Tips & Gotchas
Always verify your domain in the
