PHPackages                             boundstate/yii2-mailgun - 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. boundstate/yii2-mailgun

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

boundstate/yii2-mailgun
=======================

Mailgun integration for the Yii framework

v1.4.0(5y ago)28160.6k↓10.1%37[1 PRs](https://github.com/boundstate/yii2-mailgun/pulls)Apache-2.0PHP

Since May 12Pushed 3y ago7 watchersCompare

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

READMEChangelog (9)Dependencies (6)Versions (11)Used By (0)

Mailgun Extension for Yii 2
===========================

[](#mailgun-extension-for-yii-2)

This extension provides a [Mailgun](https://www.mailgun.com/) mail solution for [Yii framework 2.0](http://www.yiiframework.com).

[![Latest Stable Version](https://camo.githubusercontent.com/afb5248fd7ec2b22a61311c7cf2dba257777e34a2b6ec6916f0e88e83f3376dd/68747470733a2f2f706f7365722e707567782e6f72672f626f756e6473746174652f796969322d6d61696c67756e2f762f737461626c65)](https://packagist.org/packages/boundstate/yii2-mailgun)[![Total Downloads](https://camo.githubusercontent.com/6381e240a3216a5f54047caca05240e1a933bb926e030b64f5943e46c99e5377/68747470733a2f2f706f7365722e707567782e6f72672f626f756e6473746174652f796969322d6d61696c67756e2f646f776e6c6f616473)](https://packagist.org/packages/boundstate/yii2-mailgun)[![Build Status](https://camo.githubusercontent.com/3b01557ee42084847cbcfb3bb6608474708058d45bc5a704256643aec467826e/68747470733a2f2f7472617669732d63692e636f6d2f626f756e6473746174652f796969322d6d61696c67756e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/boundstate/yii2-mailgun)

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

[](#installation)

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

```
composer require boundstate/yii2-mailgun

```

The [Mailgun API Client](https://github.com/mailgun/mailgun-php) is not hard coupled to Guzzle, Buzz or any other library that sends HTTP messages. You must also install the [PSR-7 implementation and HTTP client](https://packagist.org/providers/php-http/client-implementation)you want to use.

If you just want to get started quickly you should install [Buzz](https://github.com/kriswallsmith/Buzz) and [nyholm/psr7](https://github.com/Nyholm/psr7):

```
composer require kriswallsmith/buzz nyholm/psr7
```

Usage
-----

[](#usage)

To use this extension, simply add the following code in your application configuration:

```
return [
    //....
    'components' => [
        'mailer' => [
            'class' => 'boundstate\mailgun\Mailer',
            'key' => 'key-example',
            'domain' => 'mg.example.com',
        ],
    ],
];
```

You can then send an email as follows:

```
Yii::$app->mailer->compose('contact/html', ['contactForm' => $form])
    ->setFrom('from@domain.com')
    ->setTo($form->email)
    ->setSubject($form->subject)
    ->send();
```

You can also specify an array of addresses and/or speicfy names:

```
$message->setTo(['bob@example.com' => 'Bob']);
```

> **Warning**: By default all recipients' email address will show up in the `to` field for each recipient. Enable batch sending to avoid this.

### Batch Sending

[](#batch-sending)

When [batch sending](https://documentation.mailgun.com/en/latest/user_manual.html#batch-sending) is enabled, Mailgun sends each recipient an individual email with only their email in the `to` field.

To use batch sending, set the `messageClass` to `boundstate\mailgun\BatchMessage` in your application configuration:

```
'mailer' => [
    'class' => 'boundstate\mailgun\Mailer',
    'messageClass' => 'boundstate\mailgun\BatchMessage',
    // ...
]
```

Composing a batch email is similar to regular emails, except you may define and use recipient variables:

```
Yii::$app->mailer->compose('hello')
    ->setTo([
      'bob@example.com' => [
        'id': 3,
        'full_name' => 'Bob'
      ],
      'jane@example.com' => [
        'id': 4,
        'full_name' => 'Jane'
      ],
    ])
    ->setSubject('Hi %recipient.full_name%')
    ->send();
```

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

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity46

Moderate usage in the ecosystem

Community22

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 78.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

Every ~261 days

Recently: every ~116 days

Total

9

Last Release

1929d ago

Major Versions

v0.0.4 → v1.0.02019-10-28

### Community

Maintainers

![](https://www.gravatar.com/avatar/2c8f627574f6bee1e622a2c9ada35d4347e67f6c92377bb80045c7c6661f390c?d=identicon)[mikejpeters](/maintainers/mikejpeters)

---

Top Contributors

[![mikejpeters](https://avatars.githubusercontent.com/u/3334654?v=4)](https://github.com/mikejpeters "mikejpeters (26 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")[![gattir](https://avatars.githubusercontent.com/u/9007655?v=4)](https://github.com/gattir "gattir (1 commits)")[![Lachee](https://avatars.githubusercontent.com/u/1355848?v=4)](https://github.com/Lachee "Lachee (1 commits)")[![mrstroz](https://avatars.githubusercontent.com/u/771899?v=4)](https://github.com/mrstroz "mrstroz (1 commits)")[![OllieDay](https://avatars.githubusercontent.com/u/9725880?v=4)](https://github.com/OllieDay "OllieDay (1 commits)")[![denis909](https://avatars.githubusercontent.com/u/16691851?v=4)](https://github.com/denis909 "denis909 (1 commits)")[![robregonm](https://avatars.githubusercontent.com/u/1051457?v=4)](https://github.com/robregonm "robregonm (1 commits)")

---

Tags

emailmailmailermailgunyiiyii2mailemailmaileryii2extensionmailgunrackspace

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/boundstate-yii2-mailgun/health.svg)

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

###  Alternatives

[yarcode/yii2-mailgun-mailer

Mailgun mailer implementation for Yii2

1576.0k](/packages/yarcode-yii2-mailgun-mailer)[djagya/yii2-sparkpost

A library provides Yii2 integration with SparkPost mail service

1816.3k](/packages/djagya-yii2-sparkpost)[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)
