mtymek/mt-mail
Composer 安装命令:
composer require mtymek/mt-mail
包简介
Zend Framework e-mail module. Using this library can easily create e-mail messages from PHTML templates (with optional layouts) and send them using configurable transports. Pluggable, EventManager-driven architecture allows you to customize every aspect of the process.
README 文档
README
Introduction
MtMail handles common activities surrounding sending e-mail from applications, mainly creating messages from templates, and sending them through transport adapters.
Features:
- factory for creating e-mail messages
- factory for e-mail transport adapters, service for one-line dispatch
- rendering templates from
phtmlfiles, usingZend\ViewandPhpRenderer - rendering templates with layouts
- plugins for various common tasks: from setting default headers to generating plaintext version of HTML message
- plugin support via dedicated plugin managers
Installation
Installation is supported via Composer:
$ composer require mtymek/mt-mail
Creating e-mails
Configuration
By default MtMail doesn't require any extra configuration. It will use Zend\View to render
templates accessible by your application.
Usage
Creating message from controller:
$mailService = $this->getServiceLocator()->get(\MtMail\Service\Mail::class); $headers = [ 'to' => 'johndoe@domain.com', 'from' => 'contact@mywebsite.com', ]; $variables = [ 'userName' => 'John Doe', ]; $message = $mailService->compose($headers, 'application/mail/welcome.phtml', $variables);
This snippet will create a message, compose it with $headers and HTML body
rendered from welcome.phtml template (injected with $variables array).
Layouts
In order to give your e-mails common layout, you have to enable "Layout" plugin and tell it where to look for layout template:
return [ 'mt_mail' => [ 'composer_plugins' => [ 'Layout', ], 'layout' => 'application/mail/layout.phtml', ], ];
For more info about composing e-mail messages, check [the documentation](doc/Composing messages.md). You can also check [documentation for plugins](doc/Composer Plugins.md).
Sending e-mails
Configuration
Update your application config:
return [ 'mt_mail' => [ 'transport' => \Zend\Mail\Transport\Smtp::class, 'transport_options' => [ 'host' => 'some-host.com', 'connection_class' => 'login', 'connection_config' => [ 'username' => 'user', 'password' => 'pass', 'ssl' => 'tls', ], ], ], ];
Usage
Add following code to your controller:
// create and configure message $message = new Message(); $message->addTo('johndoe@domain.com'); // ... // send! $mailService = $this->getServiceLocator()->get(\MtMail\Service\Mail::class); $mailService->send($message);
For more info on sending e-mails, check [the documentation](doc/Sending messages.md).
mtymek/mt-mail 适用场景与选型建议
mtymek/mt-mail 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 39.66k 次下载、GitHub Stars 达 18, 最近一次更新时间为 2013 年 11 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「email」 「zf2」 「module」 「e-mail」 「mail transport」 「mail template」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 mtymek/mt-mail 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mtymek/mt-mail 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 mtymek/mt-mail 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
LosLog provides some log utility
EdpModuleLayouts is very simple Laminas module for making module-specific layouts insanely easy.
Zend Framework module to leverage the symfony dependency injection container
RCM User HTML views/pages
Builds a Bridge between Zend Expressive and Plugin Managers of Zend\MVC
Extensible library for building notifications and sending them via different delivery channels.
统计信息
- 总下载量: 39.66k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 20
- 点击次数: 18
- 依赖项目数: 3
- 推荐数: 0
其他信息
- 授权协议: BSD
- 更新时间: 2013-11-11