承接 cpsit/typo3-mailqueue 相关项目开发

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

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

cpsit/typo3-mailqueue

Composer 安装命令:

composer require cpsit/typo3-mailqueue

包简介

TYPO3 CMS extension to improve TYPO3's mail spooler with additional components

README 文档

README

Extension icon

TYPO3 extension mailqueue

Coverage CGL Release License
Version Downloads Supported TYPO3 versions Extension stability

📦 Packagist | 🐥 TYPO3 extension repository | 💾 Repository | 🐛 Issue tracker

An extension for TYPO3 CMS that extends TYPO3's mail spooling functionality with an extended queueable mail transport interface. In addition, it provides an improved version of TYPO3's FileSpooler. In order to make mails in the mail queue visible, the extension provides an (admin-only) backend module and console commands to list and flush the mail queue.

🚀 Features

  • Extended interface for queueable mail transports
  • Improved queueable file transport with failure metadata
  • Backend module to list mails in queue
  • Console command to list queue and flush mails
  • Compatible with TYPO3 13.4 LTS

🔥 Installation

Composer

composer require cpsit/typo3-mailqueue

TER

Alternatively, you can download the extension via the TYPO3 extension repository (TER).

⚡ Usage

Note

In order to use a queueable mail transport, you need to configure it in your system settings, along with the required transport settings.

Concept

The extension builds on TYPO3's mail spooling feature. It provides an extended interface CPSIT\Typo3Mailqueue\Mail\Transport\QueueableTransport for TYPO3\CMS\Core\Mail\DelayedTransportInterface with additional methods to enqueue and dequeue mails:

  • public function getMailQueue(): Mail\Queue\MailQueue

    Returns an instance of CPSIT\Typo3Mailqueue\Mail\Queue\MailQueue that holds all currently enqueued mails as instances of CPSIT\Typo3Mailqueue\Mail\Queue\MailQueueItem.

  • public function enqueue(Mime\RawMessage $message, ?Mailer\Envelope $envelope = null): Mail\Queue\MailQueueItem

    Allows to enqueue a mail to the mail queue. This is basically identical to the send() method provided by the base Symfony\Component\Mailer\Transport\TransportInterface.

  • public function dequeue(Mail\Queue\MailQueueItem $item, Mailer\Transport\TransportInterface $transport): bool

    Sends the message of a given mail queue item with the provided "real" transport, effectively dequeuing it from the mail queue. This is basically identical to the flushQueue() method provided by the base TYPO3\CMS\Core\Mail\DelayedTransportInterface with the difference that it only dequeues the given mail queue item and leaves the rest of the queue untouched.

  • public function delete(Mail\Queue\MailQueueItem $item): bool

    Deletes the message of a given mail queue item without sending it. The message is also dequeued from the mail queue.

Recoverable transports

Next to the QueueableTransport interface there exists an extended interface CPSIT\Typo3Mailqueue\Mail\Transport\RecoverableTransport. It allows to recover stuck mails with a configured recover timeout:

  • public function recover(int $timeout = 900): void
    Recovers mails that are enqueued for longer than the given timeout (in seconds) and are in "sending" state. Recovering a mail resets their mail state from "sending" to "queued". They will then be sent again on dequeue or when the mail queue is flushed.

Backend module

Note

Only administrators can see the backend module.

Screenshot backend module

The backend module lists all currently enqueued mails. In addition, for supported transports it may also show transport failure details. It can be used to get a quick overview about the health state of the mail queue. It also allows to dequeue single mails from the mail queue by sending them with the configured real transport.

Console commands

Flush queue

Screenshot "mailqueue:flushqueue" console command

The extension provides a console command to flush the mail queue:

typo3 mailqueue:flushqueue [-l|--limit] [-r|--recover-timeout] [-j|--json]

The number of mails to be sent can be limited with --limit (or -l). If no limit is passed, the whole mail queue is flushed.

For transports implementing the RecoverableTransport interface, the recover timeout can be configured with --recover-timeout (or -r).

When using --json (or -j), user-oriented output is written to stderr and result messages are written in JSON format to stdout.

List queue

Screenshot "mailqueue:listqueue" console command

The extension provides a console command to list enqueued mails:

typo3 mailqueue:listqueue [-s|--strict] [-w|--watch]

With --strict (or -s) enabled, the command exits with a non-zero exit code in case any enqueued mail could not be delivered because of a failure.

In addition, a watch mode can be enabled with --watch (or -w) which updates the list every five seconds. The watch mode can be exited with Ctrl+C.

Available transports

The extension provides two custom implementations as XClasses for TYPO3's native mail spoolers:

TYPO3 core implementation Custom implementation (XClass)
TYPO3\CMS\Core\Mail\FileSpool CPSIT\Typo3Mailqueue\Mail\Transport\QueueableFileTransport
TYPO3\CMS\Core\Mail\MemorySpool CPSIT\Typo3Mailqueue\Mail\Transport\QueueableMemoryTransport

📂 Configuration

Mail settings

Queueable mail transports are registered the "normal" way as described in the official TYPO3 core documentation. Add the following to your system configuration (e.g. in additional.php/AdditionalConfiguration.php):

# File transport
$GLOBALS['TYPO3_CONF_VARS']['MAIL']['transport_spool_type'] = 'file';
$GLOBALS['TYPO3_CONF_VARS']['MAIL']['transport_spool_filepath'] = '/path/to/mailqueue';

# Memory transport
$GLOBALS['TYPO3_CONF_VARS']['MAIL']['transport_spool_type'] = 'memory';

# Use any other custom mail transport
# Note: Custom transports must implement CPSIT\Typo3Mailqueue\Mail\Transport\QueueableTransport interface!
$GLOBALS['TYPO3_CONF_VARS']['MAIL']['transport_spool_type'] = \Vendor\Extension\Mail\Transport\CustomQueueableTransport::class;

Extension configuration

The following extension configuration options are available:

Configuration key Description Required Default
queue.delayThreshold Number in seconds after which a mail in the queue is considered "delayed" 1800
pagination.itemsPerPage Number of mails to display on a single page in backend module 20

🧑‍💻 Contributing

Please have a look at CONTRIBUTING.md.

💎 Credits

The extension icon ("envelope-open") as well as the icon for the backend module are modified versions of the original actions-envelope-open icon from TYPO3 core which is originally licensed under MIT License.

⭐ License

This project is licensed under GNU General Public License 2.0 (or later).

cpsit/typo3-mailqueue 适用场景与选型建议

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

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

围绕 cpsit/typo3-mailqueue 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 5
  • Watchers: 5
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2024-03-04