2017 © Pedro Peláez
 

yii2-extension yii2-mailer-queue

使用队列异步发送邮件.

image

zangsilu/yii2-mailer-queue

使用队列异步发送邮件.

  • Sunday, September 10, 2017
  • by zangsilu
  • Repository
  • 1 Watchers
  • 3 Stars
  • 20 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 2 Versions
  • 5 % Grown

The README.md

yii2-mailer-queue

使用队列异步发送邮件v1.0.0, (*1)

环境

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

安装

composer require zangsilu/yii2-mailer-queue

使用

  • 1:配置文件配置
<?php
'components'   => [
        'redis' => [
            'class' => 'yii\redis\Connection',
            'hostname' => '127.0.0.1',
            'port' => 6379,
            'database' => 0,
        ],
        /* 邮件发送设置 */
        'mailer'       => [
            'class'            => 'zangsilu\mailerqueue\MailerQueue',
            'redisDB'=>1,//使用redis1号库存储邮件队列
            'useFileTransport' => false, //必须改为false,true只是生成邮件在runtime文件夹下,不发邮件
            'transport'        => [
                'class'      => 'Swift_SmtpTransport',
                'host'       => 'smtp.163.com',
                'username'   => '',
                'password'   => '',
                'port'       => '465',//端口25对应tls协议 端口465对应ssl协议
                'encryption' => 'ssl',
            ],
        ],
    ];
  • 2:创建控制台指令
<?php

namespace app\commands;


use Yii;
use yii\console\Controller;

class MailerQueueController extends Controller
{

    /**
     * 发送redis队列中的邮件
     * php yii mailer-queue/send
     */
    public function actionSend()
    {
        $mailer = Yii::$app->mailer;
        $mailer->process();
        echo '发送完毕!';
    }

}
  • 3:将指令加入lunux定时任务(每分钟检测一次)
crontab -e
*/1 * * * * php yii mailer-queue/send > ./log/mailer-send.log

帮助

  • 意见、BUG反馈: https://github.com/zangsilu/yii2-mailer-queue/issues

支持

  • 官方网址: http://blog2.pl39.com/
  • composer: https://getcomposer.org/

License

MIT, (*2)

The Versions

10/09 2017

dev-master

9999999-dev

使用队列异步发送邮件.

  Sources   Download

MIT

The Requires

 

by Avatar zangsilu

yii2 redis mailer async

10/09 2017

1.0.0

1.0.0.0

使用队列异步发送邮件.

  Sources   Download

MIT

The Requires

 

by Avatar zangsilu

yii2 redis mailer async