yarcode / yii2-async-mailer
为 Yii2 的异步邮件发送装饰器
0.4
2017-11-28 15:34 UTC
Requires
- bazilio/yii2-async: ^0.2.0
- yarcode/yii2-daemon: ^0.3
- yiisoft/yii2: ~2
This package is not auto-updated.
Last update: 2024-09-14 19:09:31 UTC
README
为 Yii2 的异步邮件发送装饰器
安装
安装此扩展的首选方式是通过 Composer。
运行以下命令之一
php composer.phar require --prefer-dist yarcode/yii2-async-mailer
或者添加
"yarcode/yii2-async-mailer": "*"
用法
配置您应用程序的 async
组件。详细信息请参阅此处:https://packagist.org.cn/packages/bazilio/yii2-async
将 YarCode\Yii2\AsyncMailer\Mailer
配置为您的首选邮件发送器。
'mailer' => [
'class' => '\YarCode\Yii2\AsyncMailer\Mailer',
'syncMailer' => [
'class' => 'yii\swiftmailer\Mailer',
'useFileTransport' => true,
],
],
将邮件发送命令添加到控制台配置文件。
'controllerMap' => [
'mailer' => [
'class' => '\YarCode\Yii2\AsyncMailer\MailerCommand',
],
],
在后台运行邮件发送守护进程。
yii mailer/daemon
现在您可以像往常一样发送电子邮件。
$message = \Yii::$app->mailer->compose()
->setSubject('test subject')
->setFrom('test@example.org')
->setHtmlBody('test body')
->setTo('user@example.org');
\Yii::$app->mailer->send($message);