All Projects → Tigrov → yii2-mailqueue

Tigrov / yii2-mailqueue

Licence: MIT license
Yii2 mail queue component for yii2-swiftmailer.

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to yii2-mailqueue

yii2-queuemanager
Yii2 Queue Manager (Analytic & Monitor)
Stars: ✭ 18 (+20%)
Mutual labels:  yii2, queue, yii2-extension
Crontab
Yii2 extension for crontab support
Stars: ✭ 170 (+1033.33%)
Mutual labels:  yii2, yii2-extension
Balance
Balance accounting (bookkeeping) system based on debit and credit principle
Stars: ✭ 162 (+980%)
Mutual labels:  yii2, yii2-extension
content
Content management system for Yii2
Stars: ✭ 54 (+260%)
Mutual labels:  yii2, yii2-extension
Yii2 Assets Auto Compress
Automatic compilation of js + css + html
Stars: ✭ 147 (+880%)
Mutual labels:  yii2, yii2-extension
Yii2 Comments
Comments module for Yii2
Stars: ✭ 155 (+933.33%)
Mutual labels:  yii2, yii2-extension
Ar Softdelete
Soft delete behavior for ActiveRecord
Stars: ✭ 188 (+1153.33%)
Mutual labels:  yii2, yii2-extension
Yii2 Cart
Yii2 shopping cart
Stars: ✭ 118 (+686.67%)
Mutual labels:  yii2, yii2-extension
yii2-symfonymailer
Yii 2 Symfony mailer extension.
Stars: ✭ 29 (+93.33%)
Mutual labels:  mail, yii2
yii2-lets-talk
With this extension you can open chat with someone in popular messengers using the link on your website.
Stars: ✭ 15 (+0%)
Mutual labels:  yii2, yii2-extension
Mail
Library to send e-mails over different transports and protocols (like SMTP and IMAP) using immutable messages and streams. Also includes SMTP server.
Stars: ✭ 399 (+2560%)
Mutual labels:  mail, queue
Yii2 Wx
这可能是yii2中最好用的微信SDK🔥🔥🔥
Stars: ✭ 148 (+886.67%)
Mutual labels:  yii2, yii2-extension
Yii2 Rbac
RBAC Manager for Yii 2
Stars: ✭ 128 (+753.33%)
Mutual labels:  yii2, yii2-extension
Yii2 Workflow
A simple workflow engine for Yii2
Stars: ✭ 157 (+946.67%)
Mutual labels:  yii2, yii2-extension
Yii2fullcalendar
JQuery Fullcalendar Yii2 Extension
Stars: ✭ 120 (+700%)
Mutual labels:  yii2, yii2-extension
Yii2 Enhanced Gii
Enhanced Yii2 Gii (generator) that generates related Models & CRUD
Stars: ✭ 183 (+1120%)
Mutual labels:  yii2, yii2-extension
yii2-deferred-tasks
Yii2 extension for handling deferred tasks (background cron jobs)
Stars: ✭ 11 (-26.67%)
Mutual labels:  yii2, queue
Yii2 Phone Input
Yii2 International telephone numbers
Stars: ✭ 114 (+660%)
Mutual labels:  yii2, yii2-extension
File Storage
File storage abstraction for Yii2
Stars: ✭ 116 (+673.33%)
Mutual labels:  yii2, yii2-extension
Yii2 Translate Manager
Translation Manager
Stars: ✭ 221 (+1373.33%)
Mutual labels:  yii2, yii2-extension

yii2-mailqueue

Yii2 mail queue component for yii2-swiftmailer.

Latest Stable Version

Limitation

Since 1.1.1 requires PHP >= 7.0

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist tigrov/yii2-mailqueue "~1.1.1"

or add

"tigrov/yii2-mailqueue": "~1.1.1"

to the require section of your composer.json file.

Configuration

Once the extension is installed, add following code to your application configuration:

return [
    // ...
    'components' => [
        'mailer' => [
            'class' => 'tigrov\mailqueue\Mailer',
            'table' => '{{%mail_queue}}',
            'maxAttempts' => 5,
            'attemptIntervals' => [0, 'PT10M', 'PT1H', 'PT6H'],
            'removeFailed' => true,
            'maxPerPeriod' => 10,
            'periodSeconds' => 1,
        ],
    ],
    // ...
];

Following properties are available for customizing the mail queue behavior.

  • table name of the database table to store emails added to the queue;
  • maxAttempts maximum number of sending attempts per email;
  • attemptIntervals seconds or interval specifications to delay between attempts to send a mail message, see http://php.net/manual/en/dateinterval.construct.php;
  • removeFailed indicator to remove mail messages which were not sent in maxAttempts;
  • maxPerPeriod number of mail messages which could be sent per periodSeconds;
  • periodSeconds period in seconds which indicate the time interval for maxPerPeriod option.

Updating database schema

Run yii migrate command in command line:

php yii migrate/up --migrationPath=@vendor/tigrov/yii2-mailqueue/src/migrations/

Sending the mail queue

To sending mails from the queue call Yii::$app->mailer->sending() or run the console command yii mailqueue which can be triggered by a CRON job:

* * * * * php /var/www/vhosts/domain.com/yii mailqueue/sending

After the mail message successfully sent it will be deleted from the queue.

Usage

You can then send a mail to the queue as follows:

Yii::$app->mailer->compose('contact/html')
     ->setFrom('[email protected]')
     ->setTo($form->email)
     ->setSubject($form->subject)
     ->setTextBody($form->body)
     ->delay('PT3M') // seconds or an interval specification to delay of sending the mail message, see http://php.net/manual/en/dateinterval.construct.php
     ->unique('unique key') // a unique key for the mail message, new message with the same key will replace the old one
     ->queue();

You can still send mails directly with yii2-swiftmailer:

Yii::$app->mailer->compose('contact/html')
     ->setFrom('[email protected]')
     ->setTo($form->email)
     ->setSubject($form->subject)
     ->setTextBody($form->body)
     ->send();

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].