2017 © Pedro Peláez
 

yii2-extension mailerqueue

The Async mailer for the Yii framework

image

baidumes/mailerqueue

The Async mailer for the Yii framework

  • Friday, October 27, 2017
  • by Aligp
  • Repository
  • 0 Watchers
  • 0 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

yii2-mailerqueue

async mailer 使用队列异步发送邮件, (*1)

环境

  • PHP >= 5.4
  • yiisoft/yii2-redis >= 2.0.0
  • composer

安装

composer require zangsilu/yii2-mailer-queue

使用

1. 配置文件

<?php
    'redis' => [
           'class' => 'yii\redis\Connection',
        'hostname' => 'localhost',
        'port' => 6379,
        'database' => 0,//默认16个库 0-15
    ],
    'mailer' => [
        //'class' => 'yii\swiftmailer\Mailer', //服务器类
        'class' => 'baidumes\mailerqueue\MailerQueue', 
        'db' => '1', //将邮件信息存储到redis 库 1中
        'key' => 'mails',//存到reis中的键
        'viewPath' => '@common/mail',
        'useFileTransport' => false, //这句一定有,false发送邮件,true只是生成邮件在runtime文件夹下,不发邮件
        'transport' => [
        'class' => 'Swift_SmtpTransport', //使用的类
            'host' => 'smtp.163.com', //邮箱服务一地址
            'username' => 'baidumes@163.com',
            'password' => 'gp806421831',
            'port' => '25', //服务器端口
            'encryption' => '',//加密方式
        ],
    ],
?>

2. 创建控制台指令

<?php
namespace console\controllers;

use yii\console\Controller;
use yii;

class MailerController extends Controller {
    public function actionSend() {
        Yii::$app->mailer->process();
        echo '发送完毕!';
    }
}

3. 将指令加入lunux定时任务(每分钟检测一次)

crontab -e, (*2)

*/1 * * * * php yii mailer-queue/send > ./log/mailer-send.log

The Versions

27/10 2017

dev-master

9999999-dev

The Async mailer for the Yii framework

  Sources   Download

MIT

The Requires

 

by baidumes

yii2 redis mailer async