ripaclub/zf2-mailman
Composer 安装命令:
composer require ripaclub/zf2-mailman
包简介
ZF2 module to manage email delivery
关键字:
README 文档
README
What is this?
This is a ZF2 Module that gives you a simple way to configure one or multiple mail services.
It supports all transports shipped with ZF2, e.g. any transport that implements the Zend\Mail\Transport\TransportInterface.
It also has a transport for Mandrill. If you wish to use it install also mandrill/mandrill (versions 1.0.*) library.
Installation
Add ripaclub/zf2-mailman to your composer.json.
{
"require": {
"ripaclub/zf2-mailman": "~0.3.2"
}
}
Usage
Configure a transport in your configuration file.
'mailman' => [ 'MailMan\Gmail' => [ 'default_sender' => 'my-name-is-methos@gmail.com', 'transport' => [ 'type' => 'smtp', 'options' => [ 'host' => 'smtp.gmail.com', 'port' => '587', 'connection_class' => 'login', 'connection_config' => [ 'ssl' => 'tls', 'username' => 'my-name-is-methos@gmail.com', 'password' => 'MYSECRETPASSWORD', ] ] ], ], ],
Do not forget to add MailMan module to you application.config.php file.
'modules' => [ // ... 'MailMan', 'Application', ],
Text only message
Then we send a text only message.
$message = new \MailMan\Message(); $message->addTextPart('Test email'); $message->setSubject('My name is methos'); $message->addFrom('my-name-is-methos@gmail.com', 'Methos'); $message->addTo('ripaclub@gmail.com', 'RipaClub'); /** @var \MailMan\Service\MailService $mailService */ $mailService = $this->getServiceLocator()->get('MailMan\Gmail'); $mailService->send($message);
Message with attachment
Do you want to send an email message with an attachment from filesystem?
$message = new \MailMan\Message(); $message->addAttachment('/path/to/an/attachment.png'); $message->setBody('Test email'); $message->setSubject('My name is methos'); $message->addFrom('my-name-is-methos@gmail.com', 'Methos'); $message->addTo('ripaclub@gmail.com', 'RipaClub'); /** @var \MailMan\Service\MailService $mailService */ $mailService = $this->getServiceLocator()->get('MailMan\Gmail'); $mailService->send($message);
Message using a template
$content = new ViewModel(); $content->setTemplate('email/example.phtml'); $content->setVariable('name', 'RipaClub'); $message = new \MailMan\Message(); $message->setSubject('Example email'); $message->addHtmlPart($this->getServiceLocator()->get('ViewRenderer')->render($content)); $message->addTo('ripaclub@gmail.com', 'RipaClub'); /** @var $mailService \MailMan\Service\MailService */ $mailService = $this->getServiceLocator()->get('MailMan\Gmail'); $mailService->send($message);
The content of email/example.phtml file will be:
<h2>Hi <?= $name; ?>,</h2> This is an example email with template.
Transports configuration examples
Mandrill
To use the Mandrill transport add "mandrill/mandrill" to your composer.json.
Then configure it.
'mailman' => [ 'MailMan\Mandrill' => [ 'default_sender' => 'test@mail.com', 'transport' => [ 'type' => 'mandrill', 'options' => [ 'api_key' => 'MYSECRETMANDRILLKEY', 'sub_account' => 'my-optional-subaccount-if-any' ], ], ], ]
SMTP
In this example we use the SMTP transport (shipped by ZF2).
'mailman' => [ 'MailMan\SMTP' => [ 'default_sender' => 'my-name-is-methos@gmail.com', 'transport' => [ 'type' => 'smtp', 'options' => [ 'host' => 'smtp.gmail.com', 'port' => '587', 'connection_class' => 'login', 'connection_config' => [ 'ssl' => 'tls', 'username' => 'my-name-is-methos@gmail.com', 'password' => 'MYSECRETPASSWORD', ] ] ], ], ],
Sendmail
In this example we use the Sendmail transport (shipped by ZF2).
'mailman' => [ 'MailMan\Sendmail' => [ 'default_sender' => 'my-name-is-methos@yourdomain.com', 'transport' => [ 'type' => 'sendmail' ], ], ],
ripaclub/zf2-mailman 适用场景与选型建议
ripaclub/zf2-mailman 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 371 次下载、GitHub Stars 达 6, 最近一次更新时间为 2014 年 10 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「mail」 「file」 「email」 「message」 「Zend Framework」 「smtp」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 ripaclub/zf2-mailman 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ripaclub/zf2-mailman 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 ripaclub/zf2-mailman 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
The file manager intended for using Laravel with CKEditor / TinyMCE / Colorbox
Courier offers a convenient and painless solution for creating emails tailored for your Kirby website.
Mail libraries used by Zimbra Api
Laravel Media Popup to upload/view the files
Extensible library for building notifications and sending them via different delivery channels.
Email+ extends Kirby's email capabilities by adding support for multiple email services using the same Kirby email API.
统计信息
- 总下载量: 371
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 7
- 点击次数: 20
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: BSD-2-Clause
- 更新时间: 2014-10-30