Queue mailer for Yii 2 framework
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
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
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
],
],
]