PHPackages                             atsyscorp/yii2-mailqueue - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Mail &amp; Notifications](/categories/mail)
4. /
5. atsyscorp/yii2-mailqueue

ActiveYii2-extension[Mail &amp; Notifications](/categories/mail)

atsyscorp/yii2-mailqueue
========================

Email queue component for yii2. Created by Saranga Abeykoon, updated by ATSYS

1.1.0(1y ago)033MITPHP

Since Feb 27Pushed 1y agoCompare

[ Source](https://github.com/atsyscorp/yii2-mailqueue)[ Packagist](https://packagist.org/packages/atsyscorp/yii2-mailqueue)[ Docs](https://github.com/atsyscorpcorp/yii2-mailqueue)[ RSS](/packages/atsyscorp-yii2-mailqueue/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (3)Used By (0)

yii2-mailqueue
==============

[](#yii2-mailqueue)

Email queue component for yii2 that works with [yii2-symfonymailer](https://www.yiiframework.com/extension/yiisoft/yii2-symfonymailer)

Installation
------------

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist atsyscorp/yii2-mailqueue "*"

```

or add

```
"atsyscorp/yii2-mailqueue": "*"

```

to the require section of your `composer.json` file.

Configuration
-------------

[](#configuration)

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

```
return [
    //....
    'components' => [
        'mailqueue' => [
            'class' => 'atsyscorp\mailqueue\MailQueue',
			'mailsPerRound' => 10,
			'maxAttempts' => 3,
        ],
    ],
];
```

Following properties are available for customizing the mail queue behavior.

- `mailsPerRound`: Number of emails to send at a time.
- `maxAttempts`: Maximum number of sending attempts per email.

Updating database schema
------------------------

[](#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`:

```
return [
    //....
    'components' => [
        'mailqueue' => [
            'class' => 'atsyscorp\mailqueue\MailQueue',
        ],
    ],
];
```

then run `yii migrate` command in command line:

```
php yii migrate/up --migrationPath=@vendor/atsyscorp/yii2-mailqueue/migrations/

```

Processing the mail queue
-------------------------

[](#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:

```
public function actionSend()
{
	Yii::$app->mailqueue->process();
}
```

Most preferably this could be a console command (eg: mail/send) which can be triggered by a CRON job.

Setting the CRON job
--------------------

[](#setting-the-cron-job)

Set a CRON job to run console command:

```

*/10 * * * * php /var/www/html/myapp/yii mailqueue/process

```

Usage
-----

[](#usage)

You can then send an email to the queue as follows:

```
Yii::$app->mailqueue->compose('contact/html')
     ->setFrom('from@domain.com')
     ->setTo($form->email)
     ->setSubject($form->subject)
     ->setTextBody($form->body)
     ->queue();
```

While `atsyscorp\mailqueue\MailQueue` extends from `yii\symfonymailer\Mailer`, you can replace it with this extension by adding `yii2-symfonymailer` configuations directly to `mailqueue` configurations as follows:

```
return [
    //....
    'components' => [
        'mailqueue' => [
            'class' => 'atsyscorp\mailqueue\MailQueue',
			'mailsPerRound' => 10,
			'maxAttempts' => 3,
			'transport' => [
				'class' => 'Swift_SmtpTransport',
				'host' => 'localhost',
				'username' => 'username',
				'password' => 'password',
				'port' => '587',
				'encryption' => 'tls',
			],
        ],
    ],
];
```

And use following code for directly sending emails as you ususally do with `yii2-symfonymailer`:

```
Yii::$app->mailqueue->compose('contact/html')
     ->setFrom('from@domain.com')
     ->setTo($form->email)
     ->setSubject($form->subject)
     ->setTextBody($form->body)
     ->send();
```

License
-------

[](#license)

[MIT](LICENSE)

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance46

Moderate activity, may be stable

Popularity7

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~2 days

Total

2

Last Release

433d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/90b063c0df38fe93b99b185f4ae501ded84adecccd272585cf020c87b081cb56?d=identicon)[atsyscorp](/maintainers/atsyscorp)

---

Top Contributors

[![atsyscorp](https://avatars.githubusercontent.com/u/69642420?v=4)](https://github.com/atsyscorp "atsyscorp (39 commits)")[![nterms](https://avatars.githubusercontent.com/u/1153030?v=4)](https://github.com/nterms "nterms (29 commits)")[![BBrunekreeft](https://avatars.githubusercontent.com/u/9114578?v=4)](https://github.com/BBrunekreeft "BBrunekreeft (19 commits)")[![saranga-kraken](https://avatars.githubusercontent.com/u/9246092?v=4)](https://github.com/saranga-kraken "saranga-kraken (5 commits)")[![3064709](https://avatars.githubusercontent.com/u/17542157?v=4)](https://github.com/3064709 "3064709 (2 commits)")[![marcogermani87](https://avatars.githubusercontent.com/u/998645?v=4)](https://github.com/marcogermani87 "marcogermani87 (2 commits)")[![peterngockhoa](https://avatars.githubusercontent.com/u/7524282?v=4)](https://github.com/peterngockhoa "peterngockhoa (2 commits)")[![macklus](https://avatars.githubusercontent.com/u/3457708?v=4)](https://github.com/macklus "macklus (1 commits)")[![akorinek](https://avatars.githubusercontent.com/u/1334533?v=4)](https://github.com/akorinek "akorinek (1 commits)")[![apolyntsev](https://avatars.githubusercontent.com/u/3885176?v=4)](https://github.com/apolyntsev "apolyntsev (1 commits)")[![beroso](https://avatars.githubusercontent.com/u/7874200?v=4)](https://github.com/beroso "beroso (1 commits)")[![diego-betto](https://avatars.githubusercontent.com/u/11378282?v=4)](https://github.com/diego-betto "diego-betto (1 commits)")

---

Tags

emailqueueyii2extensioncomponentsymfonymaileryii2-symfonymailer

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/atsyscorp-yii2-mailqueue/health.svg)

```
[![Health](https://phpackages.com/badges/atsyscorp-yii2-mailqueue/health.svg)](https://phpackages.com/packages/atsyscorp-yii2-mailqueue)
```

###  Alternatives

[nterms/yii2-mailqueue

Email queue component for yii2 that works with yii2-swiftmailer.

87129.2k2](/packages/nterms-yii2-mailqueue)[boundstate/yii2-mailgun

Mailgun integration for the Yii framework

28160.6k](/packages/boundstate-yii2-mailgun)[tigrov/yii2-mailqueue

Yii2 mail queue component for yii2-swiftmailer.

186.1k](/packages/tigrov-yii2-mailqueue)[rmrevin/yii2-postman

Mail module for Yii2.

2612.3k](/packages/rmrevin-yii2-postman)[djagya/yii2-sparkpost

A library provides Yii2 integration with SparkPost mail service

1816.3k](/packages/djagya-yii2-sparkpost)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
