mikk150/yii2-queuemailer

yii2 queue mailer component

Installs: 7 750

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 1

Forks: 3

Open Issues: 1

Type:yii2-extension

1.1.0 2019-04-25 08:14 UTC

This package is auto-updated.

Last update: 2024-04-07 15:58:56 UTC


README

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
        ],
    ],
]