elitetools/laravel-email-relay

Custom Laravel email transport that forwards mail via an HTTP relay API.

Maintainers

Package info

github.com/for4izen/laravel-email-relay

pkg:composer/elitetools/laravel-email-relay

Transparency log

Statistics

Installs: 7

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

1.3 2026-08-09 00:31 UTC

This package is auto-updated.

Last update: 2026-08-09 04:59:59 UTC


README

Latest Version on Packagist License

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

  1. Intercepts outgoing mail via a custom Symfony AbstractTransport
  2. Builds a JSON payload with type, sendToAddress, senderName, senderAddress, subject, and body
  3. POSTs to {EMAIL_RELAY_URL}/send with a Bearer token
  4. Throws an exception if the relay returns a non-2xx response

License

MIT