jetemail/jetemail-laravel
Composer 安装命令:
composer require jetemail/jetemail-laravel
包简介
JetEmail for Laravel
README 文档
README
Official Laravel SDK for the JetEmail transactional email service.
Installation
composer require jetemail/jetemail-laravel
Note: You need to create an account at jetemail.com to get a transactional API key before using this SDK.
The service provider and facade are auto-discovered by Laravel.
Configuration
Add your transactional API key to your .env file:
JETEMAIL_API_KEY=your-api-key
Optionally publish the config file:
php artisan vendor:publish --tag=jetemail-config
Laravel Mail Integration
Use JetEmail as a Laravel mail driver. Add the mailer to your config/mail.php:
'mailers' => [ 'jetemail' => [ 'transport' => 'jetemail', ], ],
Set it as your default mailer in .env:
MAIL_MAILER=jetemail
Then use Laravel's standard Mail API:
use Illuminate\Support\Facades\Mail; Mail::to('recipient@example.com')->send(new WelcomeEmail());
This works with all Laravel Mailables and Notifications out of the box.
Direct API Usage
Send a single email
use JetEmail\Laravel\Facades\JetEmail; use JetEmail\Laravel\Data\SendEmailOptions; $result = JetEmail::email->send(new SendEmailOptions( from: 'you@example.com', to: 'recipient@example.com', subject: 'Hello!', html: '<h1>Welcome</h1><p>Thanks for signing up.</p>', )); // $result['id'] - the message ID
Send with plain text
$result = JetEmail::email->send(new SendEmailOptions( from: 'you@example.com', to: 'recipient@example.com', subject: 'Hello!', text: 'Thanks for signing up.', ));
Multiple recipients, CC, BCC, Reply-To
$result = JetEmail::email->send(new SendEmailOptions( from: 'you@example.com', to: ['alice@example.com', 'bob@example.com'], subject: 'Team Update', html: '<p>Here is the latest update.</p>', cc: 'manager@example.com', bcc: ['logs@example.com'], replyTo: 'support@example.com', ));
Attachments
use JetEmail\Laravel\Data\Attachment; $result = JetEmail::email->send(new SendEmailOptions( from: 'you@example.com', to: 'recipient@example.com', subject: 'Invoice', html: '<p>Please find your invoice attached.</p>', attachments: [ Attachment::fromPath('/path/to/invoice.pdf'), Attachment::fromContent('Hello World', 'hello.txt'), ], ));
Custom headers
$result = JetEmail::email->send(new SendEmailOptions( from: 'you@example.com', to: 'recipient@example.com', subject: 'Tracked Email', html: '<p>Hello</p>', headers: [ 'X-Campaign-Id' => 'welcome-2024', ], ));
Batch send (up to 100 emails)
$result = JetEmail::batch->send([ new SendEmailOptions( from: 'you@example.com', to: 'alice@example.com', subject: 'Hello Alice', html: '<p>Hi Alice!</p>', ), new SendEmailOptions( from: 'you@example.com', to: 'bob@example.com', subject: 'Hello Bob', html: '<p>Hi Bob!</p>', ), ]); // $result['summary']['successful'] - number of emails sent // $result['results'] - per-email results
Without the facade
use JetEmail\Laravel\JetEmail; $jetemail = app(JetEmail::class); $jetemail->email->send(new SendEmailOptions(...));
Without Laravel
use JetEmail\Laravel\JetEmail; use JetEmail\Laravel\Data\SendEmailOptions; $jetemail = new JetEmail(apiKey: 'your-api-key'); $jetemail->email->send(new SendEmailOptions( from: 'you@example.com', to: 'recipient@example.com', subject: 'Hello!', html: '<p>Hello World</p>', ));
Webhooks
JetEmail can send webhook events to your application for email delivery events.
Setup
Add your webhook secret to .env:
JETEMAIL_WEBHOOK_SECRET=your-webhook-secret
The webhook endpoint is automatically registered at POST /jetemail/webhook. Point your JetEmail dashboard webhook URL to https://yourdomain.com/jetemail/webhook.
Configuration
You can customize the webhook route prefix and domain:
JETEMAIL_PATH=jetemail
JETEMAIL_DOMAIN=webhooks.yourdomain.com
Listening for events
Listen for webhook events in your EventServiceProvider or using Event::listen():
use JetEmail\Laravel\Events\Outbound\MessageDelivered; use JetEmail\Laravel\Events\Outbound\MessageBounced; use JetEmail\Laravel\Events\Outbound\MessageOpened; class EventServiceProvider extends ServiceProvider { protected $listen = [ MessageDelivered::class => [ HandleDeliveredEmail::class, ], MessageBounced::class => [ HandleBouncedEmail::class, ], ]; }
In your listener:
class HandleDeliveredEmail { public function handle(MessageDelivered $event): void { $payload = $event->payload; // $payload['id'] - event ID // $payload['type'] - 'outbound.delivered' // $payload['from'] - sender // $payload['to'] - recipient // $payload['subject'] - subject line // $payload['mx'] - receiving mail server } }
Available events
| Event Class | Webhook Type |
|---|---|
Events\Outbound\MessageQueued |
outbound.queued |
Events\Outbound\MessageDelivered |
outbound.delivered |
Events\Outbound\MessageDeferred |
outbound.deferred |
Events\Outbound\MessageBounced |
outbound.bounced |
Events\Outbound\MessageRejected |
outbound.rejected |
Events\Outbound\MessageSpam |
outbound.spam |
Events\Outbound\MessageVirus |
outbound.virus |
Events\Outbound\MessageDropped |
outbound.dropped |
Events\Outbound\MessageOpened |
outbound.opened |
Events\Outbound\MessageClicked |
outbound.clicked |
Events\Outbound\MessageComplaint |
outbound.complaint |
Signature verification
Webhook signatures are automatically verified when JETEMAIL_WEBHOOK_SECRET is set. The middleware validates:
- HMAC-SHA256 signature via the
X-Webhook-Signatureheader - Timestamp freshness via
X-Webhook-Timestamp(default: 5-minute tolerance)
You can adjust the tolerance (in seconds):
JETEMAIL_WEBHOOK_TOLERANCE=300
Error Handling
use JetEmail\Laravel\Exceptions\JetEmailException; try { JetEmail::email->send(new SendEmailOptions(...)); } catch (JetEmailException $e) { $e->getMessage(); // Error message $e->statusCode; // HTTP status code $e->response; // Full API error response }
License
MIT
jetemail/jetemail-laravel 适用场景与选型建议
jetemail/jetemail-laravel 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 04 月 01 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「email」 「sdk」 「laravel」 「jetemail」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 jetemail/jetemail-laravel 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 jetemail/jetemail-laravel 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 jetemail/jetemail-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
Alfabank REST API integration
A plugin for saving emails to a list
Sendy API implementation for Laravel
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 14
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-04-01