mateusjunges / laravel-cloudflare-mail
Cloudflare Email Service transport for Laravel.
Package info
github.com/mateusjunges/laravel-cloudflare-mail
pkg:composer/mateusjunges/laravel-cloudflare-mail
Requires
- php: ^8.4
- illuminate/http: ^12.0
- illuminate/mail: ^12.0
- illuminate/support: ^12.0
- symfony/mailer: ^7.2|^8.0
Requires (Dev)
- laravel/pint: ^1.20
- orchestra/testbench: ^10.0
- pestphp/pest: ^4.0
- phpstan/phpstan: ^2.1
- rector/rector: ^2.0
README
A Laravel mail driver for Cloudflare Email Service, the outbound email API on Cloudflare's network. Once installed and configured, the driver plugs into Laravel's mail abstraction. Setting MAIL_MAILER=cloudflare is enough to route every Mail::send, queued mailable, and notification through Cloudflare.
Requirements
PHP 8.4 or newer. Laravel 12.0 or newer. A Cloudflare account with a verified sender domain and an API token that has the email sending permission.
Installation
composer require mateusjunges/laravel-cloudflare-mail
The service provider auto registers via Laravel's package discovery. No manual registration needed.
Quick start
Set the credentials in your .env:
CLOUDFLARE_EMAIL_ACCOUNT_ID=your-account-id CLOUDFLARE_EMAIL_API_TOKEN=your-api-token MAIL_MAILER=cloudflare
Add the cloudflare mailer to config/mail.php:
'mailers' => [ // ... 'cloudflare' => [ 'transport' => 'cloudflare', ], ],
Add the credentials block to config/services.php (the same convention Laravel's built in Postmark and SES drivers follow):
'cloudflare' => [ 'account_id' => env('CLOUDFLARE_EMAIL_ACCOUNT_ID'), 'api_token' => env('CLOUDFLARE_EMAIL_API_TOKEN'), ],
That's it. Your existing mailables and notifications will now be delivered through Cloudflare. Any key set on the mailer block overrides the matching value in services.cloudflare, which is handy for scoping a second mailer entry to a different account.
Documentation
The docs/ folder covers each topic in more depth:
- Installation. Composer install, local path repositories, and provider registration.
- Configuration. Environment variables, config files, and Cloudflare dashboard setup.
- Usage. Sending mail through the facade, mailables, notifications, and queued jobs.
- Error handling. Exception types, Cloudflare error codes, and retry semantics.
License
The MIT License (MIT). See LICENSE for details.