musabsalihin / engagelab-mailer
Engagelab transport for Laravel Mail
Requires
- php: >=8.0
- ext-curl: *
Requires (Dev)
- illuminate/mail: ^10.0|^11.0|^12.0
- illuminate/support: ^10.0|^11.0|^12.0
- symfony/mailer: ^7.0|^8.0
- symfony/mime: ^7.0|^8.0
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 (
fromaddress) is allowed per message. - A maximum of 100 recipients (
toaddresses) 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.