定制 justinholtweb/craft-dispatch 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

justinholtweb/craft-dispatch

Composer 安装命令:

composer require justinholtweb/craft-dispatch

包简介

Lightweight email marketing and newsletter plugin for Craft CMS 5. Manage subscribers, send campaigns, and track delivery natively.

README 文档

README

Lightweight email marketing and newsletter plugin for Craft CMS 5. Manage subscribers, send campaigns, and track delivery — all natively within your control panel.

Editions

Feature Free Lite ($49) Pro ($79)
Subscriber management
Mailing lists 1 Unlimited Unlimited
CSV import/export
Queue-based sending 100/mo Unlimited Unlimited
Twig email templates
Unsubscribe handling (RFC 8058)
Basic send tracking
Craft User sync
Open/click analytics
Delivery dashboard
Custom transports (SES, Mailgun, etc.)
Drip sequences / automation
A/B subject line testing
Dynamic segments
Webhook integrations
REST API

Requirements

  • Craft CMS 5.0+
  • PHP 8.2+

Installation

composer require justinholtweb/craft-dispatch
php craft plugin/install dispatch

Configuration

All settings are available in the control panel under Dispatch → Settings, or you can configure them via config/dispatch.php:

<?php

return [
    'defaultFromName' => 'My Site',
    'defaultFromEmail' => 'hello@example.com',
    'defaultReplyToEmail' => '',
    'sendBatchSize' => 50,
    'sendRateLimit' => 0,
    'enableTracking' => true,
    'trackOpens' => true,
    'trackClicks' => true,
];

Usage

Subscribers

Subscribers are a custom element type with full field layout support. Create them via the CP or programmatically:

use justinholtweb\dispatch\elements\Subscriber;
use justinholtweb\dispatch\Plugin;

$subscriber = new Subscriber();
$subscriber->email = 'user@example.com';
$subscriber->firstName = 'Jane';
$subscriber->lastName = 'Doe';
Craft::$app->getElements()->saveElement($subscriber);

// Add to a mailing list
Plugin::getInstance()->subscribers->subscribe($subscriber->id, $listId);

Mailing Lists

use justinholtweb\dispatch\elements\MailingList;

$list = new MailingList();
$list->name = 'Weekly Newsletter';
$list->handle = 'weeklyNewsletter';
Plugin::getInstance()->lists->create($list);

Campaigns

Campaigns use Twig templates for email content. The template receives campaign, subscriber, and unsubscribeUrl variables:

{# Your email template #}
<h1>{{ campaign.subject }}</h1>
<p>Hi {{ subscriber.firstName ?? 'there' }},</p>
{{ content|raw }}
<p><a href="{{ unsubscribeUrl }}">Unsubscribe</a></p>

Send a campaign programmatically:

Plugin::getInstance()->campaigns->send($campaignId);

CSV Import

Upload a CSV with at minimum an email column. Optional columns: firstName (or first_name), lastName (or last_name). Imports are processed in the background via the queue.

Unsubscribe

Every email includes List-Unsubscribe and List-Unsubscribe-Post headers per RFC 8058, enabling one-click unsubscribe in supporting email clients. A subscriber preference center is also available at /dispatch/preferences.

Tracking (Lite+)

When enabled, Dispatch injects a 1×1 tracking pixel for opens and rewrites links for click tracking. All tracking URLs are HMAC-signed to prevent spoofing. View results on the Dashboard tab.

Custom Transports (Lite+)

Configure sending via Amazon SES, Mailgun, Postmark, or SendGrid under Settings → Transport. The default craft transport uses your existing Craft email configuration.

Webhooks (Pro)

Dispatch accepts inbound webhooks for bounce and complaint processing:

POST /dispatch/webhook/ses
POST /dispatch/webhook/mailgun
POST /dispatch/webhook/postmark
POST /dispatch/webhook/sendgrid

Set a webhookSecret in your settings for HMAC signature verification.

REST API (Pro)

Authenticate with a Bearer token (using your webhookSecret):

# List subscribers
curl -H "Authorization: Bearer YOUR_TOKEN" https://example.com/dispatch/api/v1/subscribers

# Subscribe
curl -X POST -H "Authorization: Bearer YOUR_TOKEN" \
  -d "email=user@example.com&list=weeklyNewsletter" \
  https://example.com/dispatch/api/v1/subscribe

# Unsubscribe
curl -X POST -H "Authorization: Bearer YOUR_TOKEN" \
  -d "email=user@example.com" \
  https://example.com/dispatch/api/v1/unsubscribe

# Campaign stats
curl -H "Authorization: Bearer YOUR_TOKEN" \
  https://example.com/dispatch/api/v1/stats?campaignId=123

Endpoints

Method Endpoint Description
GET /dispatch/api/v1/subscribers List subscribers
POST /dispatch/api/v1/subscribers Create subscriber
GET /dispatch/api/v1/lists List mailing lists
GET /dispatch/api/v1/campaigns List campaigns
GET /dispatch/api/v1/stats?campaignId= Campaign statistics
POST /dispatch/api/v1/subscribe Subscribe an email to a list
POST /dispatch/api/v1/unsubscribe Unsubscribe an email

Permissions

Permission Description
dispatch:accessPlugin Access the Dispatch CP section
dispatch:manageCampaigns Create/edit/delete campaigns
dispatch:sendCampaigns Trigger campaign sends
dispatch:manageSubscribers Create/edit/delete subscribers
dispatch:importSubscribers Import subscribers via CSV
dispatch:manageLists Create/edit/delete mailing lists
dispatch:viewDashboard View analytics dashboard
dispatch:manageSettings Modify plugin settings

Events

Dispatch fires events you can listen to in a custom module or plugin:

use justinholtweb\dispatch\elements\Campaign;
use justinholtweb\dispatch\events\CampaignEvent;
use justinholtweb\dispatch\events\SubscriberEvent;
use justinholtweb\dispatch\events\TrackingEvent;
use justinholtweb\dispatch\services\Tracker;
use yii\base\Event;

// Before a campaign sends
Event::on(Campaign::class, 'beforeSend', function (CampaignEvent $event) {
    // $event->campaign
});

// After a campaign sends
Event::on(Campaign::class, 'afterSend', function (CampaignEvent $event) {
    // $event->campaign
});

// On email open (Lite+)
Event::on(Tracker::class, Tracker::EVENT_ON_OPEN, function (TrackingEvent $event) {
    // $event->campaignId, $event->subscriberId
});

// On link click (Lite+)
Event::on(Tracker::class, Tracker::EVENT_ON_CLICK, function (TrackingEvent $event) {
    // $event->campaignId, $event->subscriberId, $event->url
});

License

This plugin is released under the Craft License.

justinholtweb/craft-dispatch 适用场景与选型建议

justinholtweb/craft-dispatch 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 04 月 03 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 justinholtweb/craft-dispatch 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 justinholtweb/craft-dispatch 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: proprietary
  • 更新时间: 2026-04-03