Download the PHP package nterms/yii2-mailqueue without Composer
On this page you can find all versions of the php package nterms/yii2-mailqueue. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download nterms/yii2-mailqueue
More information about nterms/yii2-mailqueue
Files in nterms/yii2-mailqueue
Package yii2-mailqueue
Short Description Email queue component for yii2 that works with yii2-swiftmailer.
License MIT
Homepage https://github.com/nterms/yii2-mailqueue
Informations about the package yii2-mailqueue
yii2-mailqueue
Email queue component for yii2 that works with yii2-swiftmailer
Installation
The preferred way to install this extension is through composer.
Either run
or add
to the require section of your composer.json
file.
Configuration
Once the extension is installed, add following code to your application configuration :
Following properties are available for customizing the mail queue behavior.
table
: Name of the database table to store emails added to the queue.mailsPerRound
: Number of emails to send at a time.maxAttempts
: Maximum number of sending attempts per email.
Updating database schema
Apply the database migration to create the table required to store the mail queue messages. To do this,
add following code to /config/console.php
:
then run yii migrate
command in command line:
Processing the mail queue
Now calling process()
on Yii::$app->mailqueue
will process the message queue and send out the emails.
In one of your controller actions:
Most preferably this could be a console command (eg: mail/send) which can be triggered by a CRON job.
Setting the CRON job
Set a CRON job to run console command:
Usage
You can then send an email to the queue as follows:
While nterms\mailqueue\MailQueue
extends from yii\swiftmailer\Mailer
, you can replace it with this extension by adding
yii2-swiftmailer
configuations directly to mailqueue
configurations as follows:
And use following code for directly sending emails as you ususally do with yii2-swiftmailer
:
License
MIT