musabsalihin/engagelab-mailer

Engagelab transport for Laravel Mail

Maintainers

Package info

github.com/musabsalihin/engagelab-mailer

pkg:composer/musabsalihin/engagelab-mailer

Transparency log

Statistics

Installs: 44

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

0.1 2026-05-27 08:43 UTC

This package is auto-updated.

Last update: 2026-06-27 08:56:35 UTC


README

A custom EngageLab mail transport for Laravel, built on top of Symfony Mailer.

Requirements

  • PHP >= 8.0
  • Laravel 10, 11, or 12
  • ext-curl

Installation

composer require musabsalihin/engagelab-mailer

The service provider is auto-discovered by Laravel. No manual registration needed.

Configuration

Add the following to your .env file and replace the ENGAGELAB_MAIL_API_USER and ENGAGELAB_MAIL_API_KEY with your own value:

ENGAGELAB_MAIL_URL=https://email.api.engagelab.cc
ENGAGELAB_MAIL_SANDBOX=true
ENGAGELAB_MAIL_API_USER=your-api-user
ENGAGELAB_MAIL_API_KEY=your-api-key

To enable the mail transporter in production, set ENGAGELAB_MAIL_SANDBOX to false. This is to safeguard the email is not sent by accident.

Add the engagelab mailer to config/mail.php under the mailers array:

'mailers' => [
    // ...

    'engagelab' => [
        'transport' => 'engagelab',
        'api_url' => env('ENGAGELAB_MAIL_URL', 'https://email.api.engagelab.cc'),
        'sandbox' => env('ENGAGELAB_MAIL_SANDBOX', true),
        'user' => env('ENGAGELAB_MAIL_API_USER'),
        'key' => env('ENGAGELAB_MAIL_API_KEY'),
    ],
],

Set MAIL_MAILER=engagelab in your .env to use it as the default mailer:

MAIL_MAILER=engagelab

Usage

Use Laravel Mail as you normally would:

use Illuminate\Support\Facades\Mail;

Mail::to('recipient@example.com')->send(new YourMailable());

Constraints

  • Only 1 sender (from address) is allowed per message.
  • A maximum of 100 recipients (to addresses) are allowed per message.

Sandbox Mode

Set ENGAGELAB_MAIL_SANDBOX=true in your .env to enable sandbox mode. Emails will be processed by EngageLab but not actually delivered — useful for testing.

Exception Handling

The package throws EngagelabMailer\Exceptions\EngagelabMailerException when the EngageLab API returns a non-200 response. The exception message includes the EngageLab error code and description.

use EngagelabMailer\Exceptions\EngagelabMailerException;

try {
    Mail::to('recipient@example.com')->send(new YourMailable());
} catch (EngagelabMailerException $e) {
    // $e->getMessage() — "[EngageLab] <message> (<code>)"
    // $e->getCode()    — HTTP status code
}

License

MIT. See LICENSE.md.