Skip to content

mikk150/yii2-queue-mailer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Yii2 Queue mailer

Queue mailer for Yii 2 framework

Build Status codecov PHP 5.6 PHP 7.0 PHP 7.1 PHP 7.2 PHP 7.3

Installation

Either run

php composer.phar require --prefer-dist mikk150/yii2-queuemailer "*"

or add

"mikk150/yii2-queuemailer": "*"

to the require section of your composer.json file

Usage

configure Yii2 config

'components' => [
    'mailer' => [
        'class' => \mikk150\queuemailer\Mailer::class,
        'mailer' => [
            'class' => '<underlying mailer config>',
            'messageClass' => '<underlying mailer message class>',
        ],
        'queue' => 'mailer-queue', // in case you need specific queue
    ],
]

and use just like you are using underlying mailer. Emails are being queued and being sent by worker

To set up yii2 queue, please refer to https://github.com/yiisoft/yii2-queue

Retryable job

You can setup retryable job to make several attemts of mail sending.

'components' => [
    'mailer' => [
        'class' => \mikk150\queuemailer\Mailer::class,
        'jobConfig' => [
            'class' => \mikk150\queuemailer\jobs\MailRetryableJob::class,
            'attempts' => 10,
            'timeToRetry' => 600, // ten minutes
        ],
    ],
]