承接 maatify/channel-delivery 相关项目开发

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

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

maatify/channel-delivery

Composer 安装命令:

composer create-project maatify/channel-delivery

包简介

Maatify Channel Delivery — Standalone async multi-channel delivery microservice (Email, Telegram, SMS, Push...)

README 文档

README

Latest Version on Packagist

PHP Version

License

CI

Maatify Ecosystem

Overview

Maatify Channel Delivery is a standalone async multi-channel delivery microservice for sending notifications across channels like Email, Telegram, SMS, and Push.

It offloads delivery processing from your core applications, ensuring:

  • High availability
  • Background delivery processing
  • Retry mechanisms
  • Secure payload encryption
  • Controlled API ingestion

Currently, the Email channel is fully implemented and production-ready. Additional channels such as SMS, Telegram, and Push notifications are planned for future releases.

Features

  • Async Multi-Channel Queue Process notifications asynchronously using background workers.

  • Encrypted Payloads Built-in AES-256-GCM encryption for recipients and message contexts via maatify/crypto.

  • Template Rendering Uses Twig to render dynamic email templates safely.

  • Reply-To Support Optional reply_to field for admin notification emails — email goes to the admin, replies go to the customer.

  • Robust Delivery Exponential retry strategy for transient delivery failures.

  • API Key & IP Whitelisting Secure ingestion endpoints allowing only trusted origin servers.

  • Rate Limiting Redis-backed sliding window rate limiter to prevent abuse.

  • Containerized Dependency Injection Built on Slim 4 + PHP-DI for modular and testable architecture.

Architecture

The system operates as an API ingestion layer combined with background workers.

Applications enqueue notification jobs via HTTP. Workers then process the queue and deliver messages asynchronously.

Architecture Diagram

The email delivery pipeline is powered internally by the maatify/email-delivery library, which provides the rendering, transport abstraction, and delivery engine.

Email Delivery Pipeline

Client Application
↓
Channel Delivery API
↓
Encrypted Queue (Database)
↓
Worker
↓
SMTP Transport
↓
Recipient

Detailed processing steps:

  1. Enqueue Client calls /api/v1/email/enqueue.

  2. Encryption EnqueueEmailHandler encrypts recipient and context via Maatify\Crypto.

  3. Persistence Job stored securely in cd_email_queue.

  4. Worker Polling EmailQueueWorker polls pending jobs.

  5. Template Rendering Context is decrypted and injected into Twig templates.

  6. SMTP Delivery Email is sent via SmtpEmailTransport. If replyTo was set, a Reply-To header is added so replies go to the specified address.

Email Flow Diagram

Requirements

  • PHP 8.2+
  • MySQL / MariaDB
  • Redis
  • SMTP server
  • Composer

Related Projects

Installation

Clone the repository or install via Composer:

composer create-project maatify/channel-delivery
cd channel-delivery

Install dependencies:

composer install --optimize-autoloader --no-dev

Configuration

Create the environment configuration file:

cp .env.example .env

Edit .env and configure the following variables.

Application

Variable Description
APP_ENV Application environment (development / production)
APP_NAME Name of the service instance
SUPPORT_EMAIL Support contact email

Database

Variable Description
DB_HOST Database host
DB_PORT Database port
DB_DATABASE Database name
DB_USERNAME Database username
DB_PASSWORD Database password

Example:

DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=channel_delivery
DB_USERNAME=root
DB_PASSWORD=secret

Encryption (Crypto)

Queue payloads and sensitive data are encrypted using AES-256-GCM through maatify/crypto.

Variable Description
CRYPTO_ACTIVE_KEY_ID Identifier of the active encryption key
CRYPTO_KEYS JSON array containing encryption keys

Example:

CRYPTO_ACTIVE_KEY_ID=v1
CRYPTO_KEYS='[{"id":"v1","key":"replace_with_32_byte_secret_here"}]'

Key requirements:

  • Key must be exactly 32 bytes
  • Keys support rotation
  • Old keys remain for decryption only

Generate a secure 32-byte key:

php -r "echo bin2hex(random_bytes(16));"

This will generate a 32-character string, for example:

a3f9c2d1e4b5f6a7c8d9e0f1a2b3c4d5

Then place it inside the .env configuration:

CRYPTO_ACTIVE_KEY_ID=v1
CRYPTO_KEYS='[{"id":"v1","key":"a3f9c2d1e4b5f6a7c8d9e0f1a2b3c4d5"}]'

Key requirements:

  • Must be exactly 32 characters
  • Used as the symmetric encryption key for AES-256-GCM
  • Keys support rotation

SMTP

SMTP configuration used by the email delivery worker.

Variable Description
MAIL_HOST SMTP server host
MAIL_PORT SMTP server port
MAIL_USERNAME SMTP username
MAIL_PASSWORD SMTP password
MAIL_FROM_ADDRESS Default sender email
MAIL_FROM_NAME Sender display name
MAIL_ENCRYPTION Encryption type (tls / ssl)
MAIL_TIMEOUT SMTP timeout (seconds)
MAIL_DEBUG SMTP debug mode (0 = disabled)

Redis

Redis is used for rate limiting.

Variable Description
REDIS_HOST Redis host
REDIS_PORT Redis port
REDIS_PASSWORD Redis password (optional)
REDIS_DB Redis database index
RATE_LIMIT_MAX_REQUESTS Maximum requests allowed
RATE_LIMIT_WINDOW_SECONDS Rate limit window duration
TRUSTED_PROXIES Trusted proxy IPs (for X-Forwarded-For)

Example:

REDIS_HOST=127.0.0.1
REDIS_PORT=6379
RATE_LIMIT_MAX_REQUESTS=100
RATE_LIMIT_WINDOW_SECONDS=60

Quick Examples

Customer-facing email

Enqueue a transactional email (e.g., welcome, OTP, verification) sent to the customer:

curl -X POST http://localhost:8080/api/v1/email/enqueue \
  -H "Content-Type: application/json" \
  -H "X-Api-Key: your_generated_api_key" \
  -d '{
    "entity_type": "user",
    "recipient": "user@example.com",
    "template_key": "welcome",
    "language": "en",
    "sender_type": 1,
    "context": {
      "user_name": "Ahmed",
      "activation_link": "https://example.com/activate?token=abc"
    }
  }'

Admin notification with Reply-To (v1.1.0+)

Enqueue an admin notification where the email goes to the admin, and replies go to the customer:

curl -X POST http://localhost:8080/api/v1/email/enqueue \
  -H "Content-Type: application/json" \
  -H "X-Api-Key: your_generated_api_key" \
  -d '{
    "entity_type": "contact_form",
    "recipient": "admin@example.com",
    "reply_to": "customer@example.com",
    "template_key": "admin_notification",
    "language": "en",
    "sender_type": 1,
    "context": {
      "customer_name": "Ahmed",
      "customer_email": "customer@example.com",
      "customer_message": "I need help with my account."
    }
  }'

Worker Usage

Run the email worker:

php scripts/email_worker.php --batch=50 --loop --sleep=5

This worker should normally run under a process manager like Supervisor or systemd.

See the worker setup guide:

Run Worker Guide

Documentation

License

This project is open-sourced software licensed under the MIT License.

See the LICENSE file for details.

maatify/channel-delivery 适用场景与选型建议

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

它主要适用于以下技术方向: 「queue」 「email」 「sms」 「async」 「push」 「delivery」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

围绕 maatify/channel-delivery 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-12