faytec / laravel-mailbox-resend
Resend driver for beyondcode/laravel-mailbox
Requires
- php: ^8.1
- beyondcode/laravel-mailbox: ^6.0
- illuminate/bus: ^10.0|^11.0|^12.0|^13.0
- illuminate/cache: ^10.0|^11.0|^12.0|^13.0
- illuminate/http: ^10.0|^11.0|^12.0|^13.0
- illuminate/queue: ^10.0|^11.0|^12.0|^13.0
- illuminate/routing: ^10.0|^11.0|^12.0|^13.0
- illuminate/support: ^10.0|^11.0|^12.0|^13.0
- svix/svix: ^1.99
Requires (Dev)
- carthage-software/mago: ^1.46
- orchestra/testbench: ^8.0|^9.0|^10.0|^11.0
- phpstan/phpstan: ^2
- phpunit/phpunit: ^10.5|^11.0|^12.0
README
Resend inbound email driver for beyondcode/laravel-mailbox.
Installation
composer require faytec/laravel-mailbox-resend
The service provider is discovered automatically. Configure Laravel Mailbox and Resend in .env:
MAILBOX_DRIVER=resend MAILBOX_RESEND_API_KEY=re_xxxxxxxxx MAILBOX_RESEND_WEBHOOK_SECRET=whsec_xxxxxxxxx MAILBOX_RESEND_QUEUE_CONNECTION=sync MAILBOX_RESEND_RATE_LIMIT=5
Point a Resend email.received webhook at:
https://your-app.example/laravel-mailbox/resend
The first path segment follows mailbox.path from Laravel Mailbox.
The default configuration is merged automatically. To publish it:
php artisan vendor:publish --tag=mailbox-resend-config
Processing
The webhook signature is verified against the exact raw body with Svix. The driver then retrieves a fresh signed URL from Resend, downloads the complete raw MIME message, and passes it to the model configured by mailbox.model before invoking the existing Laravel Mailbox routes.
The default sync queue connection requires no worker and returns a server error when processing fails, allowing Resend to retry. For production bursts, select an asynchronous Laravel queue connection. API retrieval is limited to MAILBOX_RESEND_RATE_LIMIT jobs per second on asynchronous connections.
Workers on multiple nodes must share a cache store with atomic increments, such as Redis, for the per-second limit to apply across the whole deployment.
For Redis or database queues, configure retry_after above the job's 180-second timeout and keep the worker --timeout below retry_after. For SQS, set the visibility timeout above 180 seconds.
Queued jobs have a 180-second timeout and retry for 24 hours with delays of 5 seconds, 1 minute, 5 minutes, 30 minutes, 2 hours, 5 hours, and then 10 hours.
Resend delivery and Laravel queues are at-least-once. Mailbox handlers with side effects must be idempotent, preferably using the inbound email's stable Message-Id.
Workers must have enough memory for the complete MIME message, including attachments.
Testing
composer test
composer analyse
composer format:check
Credits
This package extracts the Resend driver proposed in beyondcode/laravel-mailbox#144 into a standalone custom driver. Thanks to Beyond Code and PR author Jason Wang for the original design and implementation.
License
MIT. See LICENSE.md.