bailangzhan/yii2-swiftmailer
Composer 安装命令:
composer require bailangzhan/yii2-swiftmailer
包简介
yii2邮件处理类
关键字:
README 文档
README
此扩展是 Yii2 swiftmailer 邮件类的封装,可直接调用并发送邮件
安装
推荐使用composer进行安装
$ php composer.phar require bailangzhan/yii2-swiftmailer
或者添加
"bailangzhan/yii2-swiftmailer": "^1.0"
到你的composer.json文件的require中
使用
配置你的mailer组件
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
'viewPath' => '@common/mail',
'useFileTransport' => false,
'transport' => [
'class' => 'Swift_SmtpTransport',
'host' => 'smtp address',
'username' => 'your email username',
'password' => 'password',
'port' => '25',
'encryption' => 'tls',
],
'messageConfig'=>[
'charset'=>'UTF-8',
'from'=>['your email username' => 'your app name']
],
],
调用Mailer
发送一封邮件
use bailangzhan\Mailer; $message = [ 'to' => '要发送给谁', 'subject' => '邮件标题', 'content' => '邮件内容', ]; $mailer = new Mailer(Mailer::TYPE_1, $messages); $result = $mailer->sendMessage();
发送模版邮件
$message = [ 'to' => '要发送给谁', 'subject' => '邮件标题', 'view' => 'mail-template', 'params' => [ 'name' => '白狼栈', ] ];
发送模版邮件不需要指定content, 但是需要配置模版名, 即view的值,假如你有一个位于 Yii::$app->mailer->viewPath目录下的 mail-template.php 模版,view 填写 mail-template 就好
批量发送邮件
$messages = [ [ 'to' => '要发送给谁', 'subject' => '邮件标题', 'content' => '邮件内容', ], [ 'to' => '要发送给谁', 'subject' => '邮件标题', 'content' => '邮件内容', 'view' => 'mail-template', 'params' => [ 'name' => '白狼栈', ] ] ]; $mailer = new Mailer(Mailer::TYPE_2, $messages); $result = $mailer->sendMessage();
许可
yii2-swiftmailer is released under the BSD 3-Clause License. See the bundled LICENSE.md for details.
bailangzhan/yii2-swiftmailer 适用场景与选型建议
bailangzhan/yii2-swiftmailer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 25 次下载、GitHub Stars 达 2, 最近一次更新时间为 2017 年 03 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「mailer」 「swiftmailer」 「yii2」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 bailangzhan/yii2-swiftmailer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 bailangzhan/yii2-swiftmailer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 bailangzhan/yii2-swiftmailer 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Parse a generic mail stream, and convert it to a SwiftMailer Message
A custom URL rule class for Yii 2 which allows to create translated URL rules
Database Spool Bundle for SwiftMailer and Symfony 3
Integrate Emogrifier plugin into SilverStripe.
A SwiftMailer transport implementation for SparkPost
Integrates swiftmailer spool transport for TYPO3.
统计信息
- 总下载量: 25
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3
- 更新时间: 2017-03-17