jbboisseau / yii2-queue-mailer
Queue mailer decorator for Yii2 framework
Installs: 6 209
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 3
Open Issues: 0
Type:yii2-extension
Requires
- php: >=5.6
- yiisoft/yii2: ~2
- yiisoft/yii2-queue: ~2
Requires (Dev)
README
Send your emails in the background using Yii2 queues.
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist jbboisseau/yii2-queue-mailer
or add
"jbboisseau/yii2-queue-mailer": "*"
Usage
Configure queue
component of your application.
You can find the details here: https://www.yiiframework.com/extension/yiisoft/yii2-queue
Configure Jbboisseau\Yii2\QueueMailer\Mailer
as your primary mailer.
'mailer' => [
'class' => \Jbboisseau\Yii2\QueueMailer\Mailer::class,
'syncMailer' => [
'class' => \yii\swiftmailer\Mailer::class,
'useFileTransport' => true,
],
],
Now you can send your emails as usual.
$message = \Yii::$app->mailer->compose()
->setSubject('test subject')
->setFrom('test@example.org')
->setHtmlBody('test body')
->setTo('user@example.org');
\Yii::$app->mailer->send($message);
You can also get a background job ID of the last send()
or sendMultiple()
call.
$jobId = \Yii::$app->mailer->getLastJobId();
Licence
MIT