PHPackages                             blackcube/yii2-mailer - 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. blackcube/yii2-mailer

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

blackcube/yii2-mailer
=====================

PHP 8.3+ Mailer integration for the Yii framework

2.0.0(5mo ago)03BSD-3-ClausePHPPHP ~8.3

Since Sep 25Pushed 5mo agoCompare

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

READMEChangelogDependencies (6)Versions (4)Used By (0)

Yii2 Mailer
===========

[](#yii2-mailer)

This extension allows the developer to use [Mailjet](https://www.mailjet.com/), [Postmark](https://postmarkapp.com/) or [SendGrid](https://sendgrid.com/) as an email transport.

[![License](https://camo.githubusercontent.com/f2ab9242d71fdae56ff57051feee5a1c8e905cbe84dfcac0b6f104dacb3d29d9/68747470733a2f2f706f7365722e707567782e6f72672f626c61636b637562652f796969322d6d61696c65722f6c6963656e7365)](https://packagist.org/packages/blackcube/yii2-mailer)

Requirements
------------

[](#requirements)

- PHP 8.3+
- Yii2 2.0.x

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

[](#installation)

If you use Packagist for installing packages, then you can update your composer.json like this:

```
{
    "require": {
        "blackcube/yii2-mailer": "~2.0.0"
    }
}
```

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

[](#configuration)

### Mailjet

[](#mailjet)

```
return [
    //...
    'components' => [
        'mailer' => [
            'class' => blackcube\mailer\mailjet\Mailer::class,
            'apiKey' => '',
            'apiSecret' => '',
        ],
    ],
];
```

### Postmark

[](#postmark)

```
return [
    //...
    'components' => [
        'mailer' => [
            'class' => blackcube\mailer\postmark\Mailer::class,
            'token' => '',
        ],
    ],
];
```

### SendGrid

[](#sendgrid)

```
return [
    //...
    'components' => [
        'mailer' => [
            'class' => blackcube\mailer\sendgrid\Mailer::class,
            'token' => '',
        ],
    ],
];
```

Usage
-----

[](#usage)

### Send a simple email

[](#send-a-simple-email)

```
Yii::$app->mailer->compose()
     ->setFrom('from@domain.com')
     ->setTo('to@domain.com')
     ->setSubject('Test email')
     ->setTextBody('This is the text body')
     ->setHtmlBody('This is the HTML body')
     ->send();
```

### Send an email using templates

[](#send-an-email-using-templates)

```
Yii::$app->mailer->compose()
     ->setFrom('from@domain.com')
     ->setTo($form->email)
     ->setTemplateId(12345)
     ->setTemplateModel([
         'firstname' => $form->firstname,
         'lastname' => $form->lastname,
     ])
     ->send();
```

For further instructions refer to the [related section in the Yii Definitive Guide](https://www.yiiframework.com/doc-2.0/guide-tutorial-mailing.html)

Running the tests
-----------------

[](#running-the-tests)

Before running the tests, you should edit the file `tests/_bootstrap.php` and configure the credentials for each service you want to test:

```
// Mailjet
define('MAILJET_FROM', '');
define('MAILJET_KEY', '');
define('MAILJET_SECRET', '');
define('MAILJET_TO', '');
define('MAILJET_TEMPLATE', 218932);
define('MAILJET_TEST_SEND', false);

// Postmark
define('POSTMARK_FROM', '');
define('POSTMARK_TOKEN', '');
define('POSTMARK_TO', '');
define('POSTMARK_TEMPLATE', 218932);
define('POSTMARK_TEST_SEND', false);

// SendGrid
define('SENDGRID_FROM', '');
define('SENDGRID_KEY', '');
define('SENDGRID_TO', '');
define('SENDGRID_TEMPLATE', 'd-xxxxxx');
define('SENDGRID_TEST_SEND', false);
```

Then run:

```
# Run all tests
vendor/bin/codecept run

# Run tests for a specific provider
vendor/bin/codecept run mailjet
vendor/bin/codecept run postmark
vendor/bin/codecept run sendgrid
```

Contributing
------------

[](#contributing)

All code contributions - including those of people having commit access - must go through a pull request and approved by a core developer before being merged. This is to ensure proper review of all the code.

Fork the project, create a [feature branch](http://nvie.com/posts/a-successful-git-branching-model/), and send us a pull request.

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance71

Regular maintenance activity

Popularity3

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity80

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 83.3% 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

Every ~2990 days

Total

2

Last Release

164d ago

Major Versions

1.0.0 → 2.0.02025-12-03

PHP version history (2 changes)1.0.0PHP &gt;=5.6.0

2.0.0PHP ~8.3

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/545714?v=4)[pgaultier](/maintainers/pgaultier)[@pgaultier](https://github.com/pgaultier)

---

Top Contributors

[![pgaultier](https://avatars.githubusercontent.com/u/545714?v=4)](https://github.com/pgaultier "pgaultier (15 commits)")[![dghyse](https://avatars.githubusercontent.com/u/8821954?v=4)](https://github.com/dghyse "dghyse (3 commits)")

---

Tags

mailemailmaileryii2Mailjet

###  Code Quality

TestsCodeception

### Embed Badge

![Health badge](/badges/blackcube-yii2-mailer/health.svg)

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

###  Alternatives

[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)

PHPackages © 2026

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