nasimail / laravel-client
Laravel client package for NasiMail with API and Laravel Mail drivers.
1.0.6
2026-06-07 19:16 UTC
Requires
- php: ^8.0
- illuminate/http: ^8.83|^9.0|^10.0|^11.0|^12.0
- illuminate/mail: ^8.83|^9.0|^10.0|^11.0|^12.0
- illuminate/support: ^8.83|^9.0|^10.0|^11.0|^12.0
Requires (Dev)
- phpunit/phpunit: ^9.6|^10.5|^11.0|^12.0
README
This package provides a Laravel client with two delivery drivers:
api: send messages to a NasiMail API instance via HTTP.mail: send using Laravel's mail transport (MAIL_MAILER, etc.).
Supported Laravel versions: 8.x to 12.x.
Note: the custom MAIL_MAILER=nasimail transport is available on Laravel 9+.
On Laravel 8, use the package api or mail driver via NasiMailClient.
Docs
- Changelog:
CHANGELOG.md - Wiki:
WIKI.md
Testing
Run tests locally:
composer install ./vendor/bin/phpunit
CI validates Laravel 8 through 12 with a PHP/Laravel matrix:
- Laravel 8.83 on PHP 8.1
- Laravel 9.52 on PHP 8.1
- Laravel 10.48 on PHP 8.2
- Laravel 11.x on PHP 8.3
- Laravel 12.x on PHP 8.4
Install in this monorepo
- Add a path repository in your app
composer.json:
{
"repositories": [
{
"type": "path",
"url": "packages/nasimail",
"options": { "symlink": true }
}
]
}
- Require the package:
composer require nasimail/laravel-client:*
- Publish config:
php artisan vendor:publish --tag=nasimail-client-config
Config
Set in .env:
NASIMAIL_DRIVER=api NASIMAIL_BASE_URL=https://nasimail.hostnasi.com NASIMAIL_SECRET_KEY=sk_live_xxx
For Laravel mail transport mode:
NASIMAIL_DRIVER=mail # optional override, otherwise uses your default Laravel mailer NASIMAIL_MAILER=log
For custom transport mode via Laravel Mail:
MAIL_MAILER=nasimail NASIMAIL_BASE_URL=https://nasimail.hostnasi.com NASIMAIL_SECRET_KEY=sk_live_xxx
The package now registers a default mail.mailers.nasimail entry automatically.
If your app overrides config/mail.php, you can add this explicitly:
'mailers' => [ // ... 'nasimail' => [ 'transport' => 'nasimail', 'base_url' => env('NASIMAIL_BASE_URL'), 'secret_key' => env('NASIMAIL_SECRET_KEY'), 'timeout' => env('NASIMAIL_TIMEOUT', 10), ], ],
Usage
use NasiMail\Laravel\NasiMailClient; $response = app(NasiMailClient::class)->send([ 'from' => 'hello@example.com', 'to' => ['user@example.com'], 'subject' => 'Hello', 'text' => 'Hi there', ]);
Troubleshooting
If you see Mailer [nasimail] is not defined:
- Ensure the package service provider is loaded.
- Ensure
.envincludes:
MAIL_MAILER=nasimail NASIMAIL_BASE_URL=https://nasimail.hostnasi.com NASIMAIL_SECRET_KEY=sk_live_xxx
- Clear cached configuration:
php artisan config:clear php artisan cache:clear