netglue/laminas-mail-utils
最新稳定版本:0.0.1
Composer 安装命令:
composer require netglue/laminas-mail-utils
包简介
A collection of straight-forward validators for Laminas mail messages and some common behaviours for transactional email messages
README 文档
README
Caution
This library is abandoned because laminas-mail has been too…
Introduction
This is a small package to scratch two primary itches
- Validate
Laminas\Mail\Messageinstances according to configurable constraints such as a maximum number of recipients, or a non-empty subject line for example. - Provide simple behaviours and interfaces for email messages that should be sent via popular transactional or marketing email service providers; for example, key/value metadata or tagging/categorisation.
Installation
composer require netglue/laminas-mail-utils
Shipped Validators
Validators can be used as part of your input filter setup, or by creating vendor specific validator chains. Here's an example of a concrete validator chain that would be helpful validating messages to be sent via the Postmark API, which imposes certain restrictions on recipients etc:
<?php declare(strict_types=1); namespace App; use Netglue\Mail\Validator\HasFromAddress; use Netglue\Mail\Validator\HasSubject; use Netglue\Mail\Validator\HasToRecipient; use Netglue\Mail\Validator\TotalFromCount; use Netglue\Mail\Validator\TotalRecipientCount; use Netglue\Mail\Validator\TotalReplyToCount; use Laminas\Validator\ValidatorChain; use Laminas\Validator\ValidatorPluginManager; final class PostmarkMessageValidator extends ValidatorChain { private const MAX_RECIPIENTS = 50; public function __construct(?ValidatorPluginManager $pluginManager = null) { parent::__construct(); if ($pluginManager) { $this->setPluginManager($pluginManager); } $this->configureDefaults(); } private function configureDefaults() : void { $this->attachByName(HasFromAddress::class); $this->attachByName(TotalFromCount::class, ['max' => 1]); $this->attachByName(HasSubject::class); $this->attachByName(HasToRecipient::class); $this->attachByName(TotalRecipientCount::class, ['max' => self::MAX_RECIPIENTS]); $this->attachByName(TotalReplyToCount::class, ['max' => 1]); } }
Shipped Traits & Interfaces
You'll find a collection of interfaces that are pretty minimal but hopefully encapsulate what a lot of transactional email service providers offer when it comes to additional features WRT sending mail - for example, assigning tags or categories to individual messages or turning click tracking or open tracking on and off.
Typically, you make a concrete descendant of Laminas\Mail\Message and implement whichever interfaces suit the provider best so that you have type safety when working with the capabilities of any given message instance. Again, using Postmark as an example, perhaps something like this:
<?php declare(strict_types=1); namespace App\Postmark\Message; use Netglue\Mail\Message\KeyValueMetadata; use Netglue\Mail\Message\KeyValueMetadataBehaviour; use Netglue\Mail\Message\OpenTracking; use Netglue\Mail\Message\OpenTrackingBehaviour; use Netglue\Mail\Message\TaggableMessage; use Netglue\Mail\Message\TaggableMessageBehaviour; use Laminas\Mail\Message; class MyPostmarkMessage extends Message implements TaggableMessage, KeyValueMetadata, OpenTracking { use OpenTrackingBehaviour; use TaggableMessageBehaviour; use KeyValueMetadataBehaviour { addMetaData as parentAddMetaData; } }
// $message is given to us from some factory or service somewhere if ($message instanceof TaggableMessage) { $someVendorApi->setMessageTag($message->getTag()); }
The plan…
… is to implement vendor specific packages that lever these utilities, with, as you may have guessed, Postmark at the top of the list currently…
The package is currently immature and subject to probable BC breaks and contributions are welcomed if this scratches any itches for you 👍
netglue/laminas-mail-utils 适用场景与选型建议
netglue/laminas-mail-utils 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 29.03k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 03 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 netglue/laminas-mail-utils 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 netglue/laminas-mail-utils 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 29.03k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 27
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-03-19