mailbino/laravel
Composer 安装命令:
composer require mailbino/laravel
包简介
Laravel SDK for Mailbino: mail driver and API client
README 文档
README
Laravel SDK for Mailbino: transactional email that's easy to test.
Provides both a Laravel mail driver (use Mail::send() as usual) and a direct API client for Mailbino-specific features like tags, metadata, scoping, and test mode.
Installation
composer require mailbino/laravel
Configuration
Add your API token to .env:
MAIL_MAILER=mailbino MAILBINO_API_TOKEN=mbn_live_xxxxxxxxxxxx
Optionally publish the config file:
php artisan vendor:publish --tag=mailbino-config
Mail driver setup
Add the mailbino mailer to config/mail.php:
'mailers' => [ 'mailbino' => [ 'transport' => 'mailbino', ], // ... ],
That's it. All Mail::send() calls now go through Mailbino.
Usage
Standard Laravel Mail (zero changes needed)
Mail::to($user)->send(new WelcomeMail($user));
With Mailbino-specific features
Use custom headers to pass tags, metadata, and scoping through the standard mail interface:
Mail::to($user)->send(new InvoiceMail($invoice)); // In your Mailable's headers() method: public function headers(): Headers { return new Headers( text: [ 'X-Mailbino-Tags' => 'invoice, billing', 'X-Mailbino-Scope-Type' => 'invoice', 'X-Mailbino-Scope-Id' => $this->invoice->id, 'X-Mailbino-Metadata' => json_encode(['amount' => $this->invoice->total]), ], ); }
Available headers:
| Header | Description |
|---|---|
X-Mailbino-Tags |
Comma-separated tags |
X-Mailbino-Scope-Type |
Scope type (e.g. order, user) |
X-Mailbino-Scope-Id |
Scope ID |
X-Mailbino-Metadata |
JSON-encoded metadata object |
X-Mailbino-Test-Recipient |
Override test recipient for this message |
X-Mailbino-External-Id |
Your own message ID (UUID) |
Direct API client
For full control, use the Mailbino facade:
use Mailbino\Laravel\Facades\Mailbino; // Send an email $result = Mailbino::send([ 'from' => 'noreply@m.yourapp.com', 'from_name' => 'Your App', 'to' => ['email' => 'user@example.com', 'name' => 'John'], 'subject' => 'Your invoice is ready', 'html' => '<h1>Invoice</h1>', 'tags' => ['invoice'], 'metadata' => ['invoice_id' => 'INV-123'], 'scope_type' => 'invoice', 'scope_id' => 'INV-123', ]); // $result = ['message_id' => '...', 'status' => 'queued'] // Query messages $messages = Mailbino::messages(['status' => 'delivered', 'to_email' => 'user@example.com']); // Get a specific message $message = Mailbino::message('a1b2c3d4-...'); // Get message events $events = Mailbino::events('a1b2c3d4-...');
Test Mode
Mailbino has built-in test mode. Enable it in the Mailbino dashboard and all emails are redirected to your test recipients with a banner showing the original address.
Option 1: Dashboard
Enable test mode on your app in the Mailbino dashboard and add your test recipients there.
Option 2: Environment variable
Set a global test recipient in .env:
MAILBINO_TEST_RECIPIENT=developer@company.com
This sends test_recipient on every API call. Combined with test mode on the app, all emails land in your inbox.
The environment variable only selects the recipient. It never enables test mode. When test mode is disabled in the Mailbino dashboard, Mailbino sends to the real recipient.
Option 3: Per-message
// Via mail headers 'X-Mailbino-Test-Recipient' => 'developer@company.com' // Via direct API Mailbino::send([ // ... 'test_recipient' => 'developer@company.com', ]);
Webhooks
Set the signing secret shown in the Mailbino app settings:
MAILBINO_WEBHOOK_SECRET=whsec_xxxxxxxxxxxx
Verify the raw request body before processing an event:
use Mailbino\Laravel\Webhooks\WebhookVerifier; $event = app(WebhookVerifier::class)->verify( $request->getContent(), $request->headers->all(), );
The verifier checks the signature, rejects stale requests and returns the decoded payload. The default timestamp tolerance is 300 seconds and can be changed with MAILBINO_WEBHOOK_TOLERANCE.
Error Handling
use Mailbino\Laravel\MailbinoException; try { Mailbino::send([...]); } catch (MailbinoException $e) { $e->statusCode; // 422 $e->apiError; // "Domain not verified." $e->apiMessage; // "The sender domain for..." }
License
MIT
mailbino/laravel 适用场景与选型建议
mailbino/laravel 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.8k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 03 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「email」 「laravel」 「transactional-email」 「mailbino」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 mailbino/laravel 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mailbino/laravel 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 mailbino/laravel 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Extensible library for building notifications and sending them via different delivery channels.
Email+ extends Kirby's email capabilities by adding support for multiple email services using the same Kirby email API.
Laravel contact us form package to send email and save to database
Official PHP SDK for the Orboto Mail Service. Drop-in transactional-mail client with auto-quota-tracking, retry-with-backoff, quota lifecycle events, typed DTOs, and a Laravel Service-Provider out of the box. EU-hosted, GDPR-compliant.
Alfabank REST API integration
A plugin for saving emails to a list
统计信息
- 总下载量: 1.8k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 21
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-03-05