jsoma / mailerqueue
The Async mailer for the Yii framework
Installs: 6
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:yii2-extension
Requires
- yiisoft/yii2: *
- yiisoft/yii2-redis: ~2.0.0
This package is not auto-updated.
Last update: 2024-05-12 02:20:42 UTC
README
yii2 redis async mailer
基于 Redis的邮件异步发送工具
1.config.php
'aliases' => [ '@jsoma/mailer'=>'@vendor/jsoma/mailerqueue/src' ],
'components' => [ ... 'redis' => [ 'class' => 'yii\redis\Connection', 'hostname' => 'localhost', // ip/127.0.0.1 'port' => 6379, 'database' => 0, ],
...
'mailer' => [
//redis 发送邮件
'class' => 'jsoma\mailer\MailerQueue',
'db' => '1', // redis select 1
'key' => 'mails', // redis key
'useFileTransport' => false,
'transport' => [
'class' => 'Swift_SmtpTransport',
'host' => 'smtp.163.com',
'username' => 'xxx@163.com',
'password' => 'xxx',
'port' => '465',
'encryption' => 'ssl',
],
],
],
-
mail to redis
$mailer = Yii::$app->mailer->compose($template, $param=[]);//邮件体 $mailer->setFrom('xxx@163.com'); //发件人 $mailer->setTo('xxx@xxx.com'); // 收件人 $mailer->setSubject('xxx'); // 邮件标题 //if ($mailer->send()) { // if ($mailer->queue()) { // redis 发送 return true; }else{ return false; }
-
Send mail by redis ( linux crontab 定时脚本)
$mailer = new \jsoma\mailer\MailerQueue(); $mailer->process();