承接 jetemail/jetemail-laravel 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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-Signature header
  • 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 我们能提供哪些服务?
定制开发 / 二次开发

基于 jetemail/jetemail-laravel 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 14
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-01