dev-master
9999999-devThe Async mailer for the Yii framework
MIT
The Requires
by Jsoma
yii2 redis mailer async
The Async mailer for the Yii framework
yii2 redis async mailer, (*1)
基于 Redis的邮件异步发送工具, (*2)
1.config.php, (*3)
'aliases' => [ '@jsoma/mailer'=>'@vendor/jsoma/mailerqueue/src' ],, (*4)
'components' => [ ... 'redis' => [ 'class' => 'yii\redis\Connection', 'hostname' => 'localhost', // ip/127.0.0.1 'port' => 6379, 'database' => 0, ],, (*5)
... '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, (*6)
$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; }, (*7)
Send mail by redis ( linux crontab 定时脚本), (*8)
$mailer = new \jsoma\mailer\MailerQueue(); $mailer->process();, (*9)
The Async mailer for the Yii framework
MIT
yii2 redis mailer async