PHPackages                             phuongdev89/yii2-email-manager - 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. phuongdev89/yii2-email-manager

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

phuongdev89/yii2-email-manager
==============================

Yii2 Email Manager

2.1.0(3y ago)0131MITPHPPHP &gt;=7.1

Since Jan 10Pushed 2y agoCompare

[ Source](https://github.com/phuongdev89/yii2-email-manager)[ Packagist](https://packagist.org/packages/phuongdev89/yii2-email-manager)[ RSS](/packages/phuongdev89-yii2-email-manager/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (9)Versions (2)Used By (0)

Installation
============

[](#installation)

Composer
--------

[](#composer)

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

Either run

```
php composer.phar require --prefer-dist phuongdev89/yii2-email-manager "@dev"

```

or add

```
"phuongdev89/yii2-email-manager": "@dev"

```

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

Migration
---------

[](#migration)

Migration run

```
php yii migrate --migrationPath=@vendor/phuongdev89/yii2-email-manager/src/migrations
```

Configuration
=============

[](#configuration)

Simple configuration:
---------------------

[](#simple-configuration)

```
    'components' => [
        'mailer'        => [
            'class'            => 'yii\swiftmailer\Mailer',
            'useFileTransport' => false,
            'host'             => 'smtp.gmail.com',
            'username'         => 'test@gmail.com',
            'password'         => '12345678',
            'port'             => '587',
            'encryption'       => 'TLS',
        ],
        'emailManager' => [
            'class' => '\phuongdev89\email\EmailManager',
            'defaultTransport' => 'yiiMailer',
            'resendAfter'      => 5,//resend after 5 mins if stuck
            'tryTime'          => 3,//max try time resend
            'transports' => [
                'yiiMailer' => [
                    'class' => '\phuongdev89\email\transports\YiiMailer',
                ],
                /*
                'mailGun' => [ //Not required
                    'class'  => '\phuongdev89\email\transports\MailGun',
                    'apiKey' => 'xxx',
                    'domain' => 'our-domain.net',
                ],
                */
            ],
        ],
    ],
    'modules' => [
        'mailer'   => [
            'class'         => 'phuongdev89\email\Module',
            'cleanAfter'    => 30//clean after days
        ],
    ]

```

Advanced config
---------------

[](#advanced-config)

First you need `phuongdev89/yii2-setting` installed, create 5 records on Setting module:

- `smtp_host` (value: `smtp.gmail.com`)
- `smtp_user` (value: `test@gmail.com`)
- `smtp_password` (value: `12345678`)
- `smtp_port` (value: `587`)
- `smtp_encryption` (value: `TLS`)

```
    'components' => [
        'mailer'        => [
            'class'            => '\phuongdev89\email\swiftmailer\Mailer',
        ],
        'emailManager'  => [
            'class'            => '\phuongdev89\email\components\EmailManager',
            'defaultTransport' => 'yiiMailer',
            'resendAfter'      => 5,//resend after 5 mins if stuck
            'tryTime'          => 3,//max try time resend
            'transports'       => [
                'yiiMailer' => [
                    'class' => '\phuongdev89\email\transports\YiiMailer',
                ],
                /*
                'mailGun' => [
                    'class'  => '\phuongdev89\email\transports\MailGun',
                    'apiKey' => 'xxx',
                    'domain' => 'our-domain.net',
                ],
                */
            ],
        ],
    ]
    'modules' => [
        'mailer'   => [
            'class'         => 'phuongdev89\email\Module',
            'cleanAfter'    => 30//clean after days
      ],
    ]

```

Add command to the list of the available commands. Put it into console app configuration:

```
    'controllerMap' => [
        'email' => '\phuongdev89\email\commands\EmailController',
    ],

```

Add email sending daemon into crontab, can be via lockrun or run-one utils (read more `phuongdev89/yii2-cron`):

```
    */5 * * * * php /your/site/path/yii email/start

```

Usage
=====

[](#usage)

\##Backend Access this url:

```
http://backend.yourdomain.com/mailer

```

or

```
http://backend.yourdomain.com/index.php?r=mailer

```

\##Simple usage

```
    // obtain component instance
    $emailManager = EmailManager::getInstance();
    // direct send via default transport
    $emailManager->send('from@example.com', 'to@example.com', 'test subject', 'test email');
    // queue send via default transport
    $emailManager->queue('from@example.com', 'to@example.com', 'test subject', 'test email');
    // direct send via selected transport
    $emailManager->transports['mailGun']->send('from@example.com', 'to@example.com', 'test subject', 'test email');

```

\##Advanced usage Create a shortcut name `welcome_email`. Example:

```
Welcome {{fullname}},
Thanks for registered at {{url}}.
Your username: {{username}}
Your phone: {{phone}}

```

Send/Queue welcome email when done:

```
    // use shortcuts
    $user = new User();
    $user->fullname = "Test ABC";
    $user->username = "testabc";
    $user->email = "test@gmail.com";
    $user->phone = "0123456789";
    ...
    if($user->save()) {
        EmailTemplate::findByShortcut('welcome_email')->queue($user->email, ['fullname' => $user->fullname, 'username' => $user->username, 'ur' => 'http://domain.com', 'phone' => $user->phone]);
    }

```

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 93.8% of commits — single point of failure

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

Unknown

Total

1

Last Release

1218d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b606411df0cf562fe1d77d5ee80c3ef2e2c34a06d93470a4127c8910132ba258?d=identicon)[phuongdev89](/maintainers/phuongdev89)

---

Top Contributors

[![BioSin](https://avatars.githubusercontent.com/u/1442288?v=4)](https://github.com/BioSin "BioSin (15 commits)")[![phuongdev89](https://avatars.githubusercontent.com/u/7648033?v=4)](https://github.com/phuongdev89 "phuongdev89 (1 commits)")

---

Tags

emailyii2modulecomponentemail queueemail manager

### Embed Badge

![Health badge](/badges/phuongdev89-yii2-email-manager/health.svg)

```
[![Health](https://phpackages.com/badges/phuongdev89-yii2-email-manager/health.svg)](https://phpackages.com/packages/phuongdev89-yii2-email-manager)
```

###  Alternatives

[nterms/yii2-mailqueue

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

87129.2k2](/packages/nterms-yii2-mailqueue)[yiimaker/yii2-email-templates

Extension for creating of email templates and manage using your site dashboard

9219.4k1](/packages/yiimaker-yii2-email-templates)[boundstate/yii2-mailgun

Mailgun integration for the Yii framework

28160.6k](/packages/boundstate-yii2-mailgun)[yarcode/yii2-mailgun-mailer

Mailgun mailer implementation for Yii2

1576.0k](/packages/yarcode-yii2-mailgun-mailer)[tigrov/yii2-mailqueue

Yii2 mail queue component for yii2-swiftmailer.

186.1k](/packages/tigrov-yii2-mailqueue)

PHPackages © 2026

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