elitetools / laravel-email-relay
Custom Laravel email transport that forwards mail via an HTTP relay API.
1.3
2026-08-09 00:31 UTC
Requires
- php: ^8.2
- laravel/framework: ^11.0|^12.0|^13.0
This package is auto-updated.
Last update: 2026-08-09 04:59:59 UTC
README
Custom Laravel email transport that forwards mail via an HTTP relay API.
Requirements
- PHP 8.2+
- Laravel 11, 12, or 13
Installation
1. Install the package:
composer require elitetools/laravel-email-relay
That's it! The package automatically registers the emailrelay mailer and its service configuration via Laravel's package discovery.
Configuration
Just set these variables in your .env file:
MAIL_MAILER=emailrelay EMAIL_RELAY_URL=https://your-relay-api.example.com EMAIL_RELAY_TOKEN=your-secret-token
Usage
Use it like any standard Laravel Mailable. Optionally set the X-Email-Type header to categorize the email on the relay side:
Mail::to($user)->send( (new WelcomeMail($user))->withSymfonyMessage(function ($message) { $message->getHeaders()->addTextHeader('X-Email-Type', 'Welcome'); }) );
How it works
- Intercepts outgoing mail via a custom Symfony
AbstractTransport - Builds a JSON payload with
type,sendToAddress,senderName,senderAddress,subject, andbody - POSTs to
{EMAIL_RELAY_URL}/sendwith a Bearer token - Throws an exception if the relay returns a non-2xx response
License
MIT