PHPackages                             simialbi/yii2-mandrill - 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. simialbi/yii2-mandrill

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

simialbi/yii2-mandrill
======================

Mandrill Api Integration for Yii2

3.0.0(2y ago)16071GPL-3.0PHPPHP &gt;=8.0

Since Aug 14Pushed 2y agoCompare

[ Source](https://github.com/simialbi/yii2-mandrill)[ Packagist](https://packagist.org/packages/simialbi/yii2-mandrill)[ RSS](/packages/simialbi-yii2-mandrill/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (2)Dependencies (5)Versions (15)Used By (0)

Mandrill API Extension
======================

[](#mandrill-api-extension)

Mandrill Api Integration for Yii2 [![Latest Stable Version](https://camo.githubusercontent.com/2fdefdc8837c0e964ede6c4760332e8075b77765528c257c616538c9220528fb/68747470733a2f2f706f7365722e707567782e6f72672f6e69636b63762f796969322d6d616e6472696c6c2f762f737461626c65)](https://packagist.org/packages/nickcv/yii2-mandrill) [![build](https://github.com/nickcv-ln/yii2-mandrill/actions/workflows/build.yml/badge.svg)](https://github.com/nickcv-ln/yii2-mandrill/actions/workflows/build.yml) [![Total Downloads](https://camo.githubusercontent.com/e22f94d6a6f03efc49ad5343d33eaff9e2fbec216fe08ec89edc0303d41d9490/68747470733a2f2f706f7365722e707567782e6f72672f6e69636b63762f796969322d6d616e6472696c6c2f646f776e6c6f616473)](https://packagist.org/packages/nickcv/yii2-mandrill) [![License](https://camo.githubusercontent.com/3c21a9853a3408cabecdd8dfc3fce74366174bfa25c7d1b0c014a947733d9def/68747470733a2f2f706f7365722e707567782e6f72672f6e69636b63762f796969322d6d616e6472696c6c2f6c6963656e7365)](https://packagist.org/packages/nickcv/yii2-mandrill)

Change Log
----------

[](#change-log)

Since **version 1.6.1** the methods `nickcv\mandrill\Message::setHtmlBody` and `nickcv\mandrill\Message::setSubject` do not purify/encode the data automatically.

This has been done to offer a greater degree of flexibility to developers, see issues [\#16](https://github.com/nickcv-ln/yii2-mandrill/issues/16) and [\#19](https://github.com/nickcv-ln/yii2-mandrill/issues/19).

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

[](#installation)

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

Either run

```
php composer.phar require --prefer-dist nickcv/yii2-mandrill "*"

```

or add

```
"nickcv/yii2-mandrill": "*"

```

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

Set Up
------

[](#set-up)

Recently Mandrill became a MailChilmp service: to use Mandrill you will need to have a [MailChimp Account](https://mandrill.com/signup/).

For details on the pricing please check [their website](https://mandrill.com/pricing/).

Once you have an account you will need to create an **API Key**. You can create as many API keys as you want, and it's best practice to create one for each website. You can also create **test API keys**. Every email submitted using a test API key will not actually be submitted, but you'll be able to check inside the **test dashboard** if the test went thorugh successfully.

Mandrill will keep track of every single email you submit. You can filter the data using tags and you'll also be able to check how many times each email was opened and if the links within it have been clicked.

Usage
-----

[](#usage)

Once the extension is installed, change your application config file `web.php`:

First of all you will need to add an `application name`. By default this extension will send every single email using the application name as the sender name and the `adminEmail` parameter inside `params.php` as the sender email.

```
[
	'id' => 'basic',
	'name' => 'Application Name',
]
```

```
return [
    'adminEmail' => 'admin@example.com',
];
```

You will then need to add the component

```
    'mailer' => [
        'class' => 'nickcv\mandrill\Mailer',
        'apikey' => 'YourApiKey',
    ],
```

From now on you can just use the mandrill mailer just as you used to use the default one.

```
\Yii::$app->mailer
    ->compose('mailViewName', ['model' => $model])
    ->setTo('email@email.com')
    ->send();
```

Mandrill Templates
------------------

[](#mandrill-templates)

You can use Mandrill's own template system if you want to, just set up as true the `useMandrillTemplates` attribute in the component configuration

```
    'mailer' => [
        'class' => 'nickcv\mandrill\Mailer',
        'apikey' => 'YourApiKey',
        'useMandrillTemplates' => true,
    ],

```

If you do turn this feature on the component will look for a template within mandrill named after the view argument of the compose method.

Since **version 1.3.0** the component will stop falling back to rendering the internal views. This change has been made because now the mandrill send-template method will be used, avoiding to make two API calls when templates are enabled.

Since **version 1.4.0** the component won't default to the application name and admin email when using mandrill templates. This has been done to allow the use of Mandrill defaults values for the template.

To override this behavior you can set to false the `useTemplateDefaults` attribute in the component configuration

```
    'mailer' => [
        'class' => 'nickcv\mandrill\Mailer',
        'apikey' => 'YourApiKey',
        'useMandrillTemplates' => true,
        'useTemplateDefaults' => false,
    ],
```

Since **version 1.5.0** the component has a configurable property `templateLanguage` that can contain either 'mailchimp' or 'handlebars' ('mailchimp' is by default).

For more information about handlebars usage check these links:

- [Mandrill docs](https://mandrill.zendesk.com/hc/en-us/articles/205582537-Using-Handlebars-for-dynamic-content)
- [Handlebars docs](http://handlebarsjs.com/)

You can change preferred language by editing `templateLanguage` attribute in the component configuration

```
    'mailer' => [
        'class' => 'nickcv\mandrill\Mailer',
        'apikey' => 'YourApiKey',
        'useMandrillTemplates' => true,
        'templateLanguage' => nickcv\mandrill\Mailer::LANGUAGE_HANDLEBARS,
    ],
```

Additional Methods
------------------

[](#additional-methods)

Mandrill lets you set up tags. The method `\nickcv\mandrill\Message::setTags($tags)` accept as an argument both a string or an array of strings:

```
\Yii::$app->mailer
    ->compose('mailViewName', ['model' => $model])
    ->setTags(['registration']);
```

Since **version 1.3.0** it's also possible to enable the async mode. When using async mode mandrill will queue the messages and send em in batches. If you send a message to more than 10 email addresses async mode will be used automatically.

```
\Yii::$app->mailer
    ->compose('mailViewName', ['model' => $model])
    ->enableAsync();
```

Since **version 1.4.0** it's also possible to use global merge vars. This variables will be use to replace placeholders by mandrill. This is especially useful when dealing with templates.

Since **version 1.6.0** you can get the Mandrill object used by the component calling the `Mailer::getMandrill` method.

For more informations check the component documentation.

Since **version 1.7.0** it's also possible to enable/disable messages clicks/opens tracking and to decide whether or not it is a priority message.

It is also possible to retrieve the full body of the response returned from Mandrill using the `Mailer::getLastTransaction` method.

**Sending Multiple Email with Mandril Template using merge\_vars**

You can consider using this method for using mandrill template and change the variable based on your data :

```
\Yii::$app->mailer
    ->compose($stringTemplate)
    ->setTo($arrayTo)
    ->setGlobalMergeVars($arrayGolbalMergeVars)
    ->setMergeVars($arrayMergeVars)
    ->send();
```

Unit Testing
------------

[](#unit-testing)

All the Classes within the package have been unit tested. The tests are included within the package.

If you wish to run the tests install phpunit following the Yii2 documentation.

The tests use the developer Mandrill Test API key which is only whitelisted for the developer IP.

Logs
----

[](#logs)

The component automatically logs every single message sent through mandrill, inside the "mandrill" category.

Messages sent successfully are logged using `\Yii::info()`, messages rejected or invalid are logged using `\Yii::warning()`, and all the exceptions thrown by the Mandrill Class are logged using `\Yii::error()`.

If you are using mandrill templates and the template is not found the error will be logged using `Yii::info()`.

###  Health Score

35

—

LowBetter than 79% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity76

Established project with proven stability

 Bus Factor1

Top contributor holds 84.6% 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 ~259 days

Recently: every ~677 days

Total

14

Last Release

913d ago

Major Versions

1.8.1 → 2.0.0-beta.22021-12-13

2.0.0-beta.2 → 3.0.02023-11-10

PHP version history (2 changes)2.0.0-beta.2PHP &gt;=7.0

3.0.0PHP &gt;=8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/8b73212dfd30ac36af7d3587675a5d7c4a5f8bfb5eb8d87eb3410617a82a4bb7?d=identicon)[nickcv](/maintainers/nickcv)

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

---

Top Contributors

[![nickcv-ln](https://avatars.githubusercontent.com/u/8384804?v=4)](https://github.com/nickcv-ln "nickcv-ln (22 commits)")[![mikk150](https://avatars.githubusercontent.com/u/4953629?v=4)](https://github.com/mikk150 "mikk150 (2 commits)")[![rabbasa](https://avatars.githubusercontent.com/u/859552?v=4)](https://github.com/rabbasa "rabbasa (2 commits)")

---

Tags

emailmaileryii2extensionmandrill

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/simialbi-yii2-mandrill/health.svg)

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

###  Alternatives

[nickcv/yii2-mandrill

Mandrill Api Integration for Yii2

29554.2k2](/packages/nickcv-yii2-mandrill)[boundstate/yii2-mailgun

Mailgun integration for the Yii framework

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

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

87129.2k2](/packages/nterms-yii2-mailqueue)[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)
