nasimail/laravel-client
Composer 安装命令:
composer require nasimail/laravel-client
包简介
Laravel client package for NasiMail with API and Laravel Mail drivers.
README 文档
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
统计信息
- 总下载量: 133
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 5
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-06-07