PHPackages                             mapkyca/swiftmailer-mailgun-transport - 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. mapkyca/swiftmailer-mailgun-transport

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

mapkyca/swiftmailer-mailgun-transport
=====================================

This is a fork of Swiftmailer Mailgun Bundle to expose the Transport layer only

1.2.0(7y ago)06.1kGPL-2.0-or-laterPHPPHP ^7.0

Since Aug 28Pushed 5y agoCompare

[ Source](https://github.com/mapkyca/swiftmailer-mailgun-transport)[ Packagist](https://packagist.org/packages/mapkyca/swiftmailer-mailgun-transport)[ Docs](https://github.com/tehplague/swiftmailer-mailgun-bundle)[ RSS](/packages/mapkyca-swiftmailer-mailgun-transport/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (13)Versions (12)Used By (0)

**THIS IS A FORK of the Mailgun bundle, produced due to a work time pressure to get the Mailgun transport working with modern symfony builds. You should probably use the original project**

Swiftmailer Mailgun bundle
==========================

[](#swiftmailer-mailgun-bundle)

[![Latest Stable Version](https://camo.githubusercontent.com/2172ec18ad336cbb812ac720ea41d8a86ceda4d240f789830ded189196b9970c/68747470733a2f2f706f7365722e707567782e6f72672f6373706f6f2f73776966746d61696c65722d6d61696c67756e2d62756e646c652f762f737461626c65)](https://packagist.org/packages/cspoo/swiftmailer-mailgun-bundle)[![codecov.io](https://camo.githubusercontent.com/0d99fc68874efaa042b8801a9bba29865620f649f856f9cead834e5e1b02e794/68747470733a2f2f636f6465636f762e696f2f6769746875622f746568706c616775652f73776966746d61696c65722d6d61696c67756e2d62756e646c652f636f7665726167652e7376673f6272616e63683d6d6173746572)](https://codecov.io/github/tehplague/swiftmailer-mailgun-bundle?branch=master)[![Total Downloads](https://camo.githubusercontent.com/eaa2fe92ff875bc2c078424c846549326d1dfcefcf807c47f8a54b4cf99d87a2/68747470733a2f2f706f7365722e707567782e6f72672f6373706f6f2f73776966746d61696c65722d6d61696c67756e2d62756e646c652f646f776e6c6f616473)](https://packagist.org/packages/cspoo/swiftmailer-mailgun-bundle)[![Monthly Downloads](https://camo.githubusercontent.com/9a87464af44b7f4d5142c3b47afbe00a51f52860c473c0f54b5d0e89ffafd9bf/68747470733a2f2f706f7365722e707567782e6f72672f6373706f6f2f73776966746d61696c65722d6d61696c67756e2d62756e646c652f642f6d6f6e74686c792e706e67)](https://packagist.org/packages/cspoo/swiftmailer-mailgun-bundle)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)

This bundle adds an extra transport to the swiftmailer service that uses the mailgun http interface for sending messages.

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

[](#installation)

```
composer require cspoo/swiftmailer-mailgun-bundle php-http/guzzle5-adapter
```

*Note: You can use any of [these adapters](https://packagist.org/providers/php-http/client-implementation)*

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

[](#configuration)

### Symfony 3.4

[](#symfony-34)

Also add to your AppKernel:

```
new cspoo\Swiftmailer\MailgunBundle\cspooSwiftmailerMailgunBundle(),
```

Configure your application with the credentials you find on the [domain overview](https://mailgun.com/app/domains) on the Mailgun.com dashboard.

```
// app/config/config.yml:
cspoo_swiftmailer_mailgun:
    key: "key-xxxxxxxxxx"
    domain: "mydomain.com"
    endpoint: "https://api.eu.mailgun.net" # Optional. Use this config for EU region. Defaults to "https://api.mailgun.net"
    http_client: "httplug.client" # Optional. Defaults to null and uses discovery to find client.

# Swiftmailer Configuration
swiftmailer:
    transport: "mailgun"
    spool:     { type: memory } # This will start sending emails on kernel.terminate event
```

Note that the swiftmailer configuration is the same as the standard one - you just change the mailer\_transport parameter.

### Symfony 4.1

[](#symfony-41)

Add your Mailgun credentials

```
# both .env and .env.dist files
MAILGUN_DOMAIN=
MAILGUN_API_KEY=
MAILGUN_SENDER=
```

Adding to you bundle

```
// config/bundles.php
return [
    ...
    cspoo\Swiftmailer\MailgunBundle\cspooSwiftmailerMailgunBundle::class => ['all' => true],
    ];
```

Configure your Mailgun credentials:

```
// config/packages/mailgun.yaml
cspoo_swiftmailer_mailgun:
    key: '%env(MAILGUN_API_KEY)%'
    domain: "%env(MAILGUN_DOMAIN)%"

services:
    Mailgun\Mailgun:
        class: Mailgun\Mailgun
        factory: ['Mailgun\Mailgun', create]
        arguments: ['%env(MAILGUN_API_KEY)%']
```

Finally, add the following line on swiftmailer config:

```
// config/packages/swiftmailer.yaml
swiftmailer:
    # url: '%env(MAILER_URL)%'
    transport: 'mailgun'
    spool: { type: 'memory' }
```

Note: Not sure if url line should be commented.

Usage
-----

[](#usage)

First craft a message:

```
$message = \Swift_Message::newInstance()
        ->setSubject('Hello Email')
        ->setFrom('send@example.com')
        ->setTo('recipient@example.com')
        ->setBody(
            $this->renderView(
                'HelloBundle:Hello:email.txt.twig',
                array('name' => $name)
            )
        )
    ;
```

Then send it as you normally would with the `mailer` service. Your configuration ensures that you will be using the Mailgun transport.

```
$this->container->get('mailer')->send($message);
```

You can also test through terminal using:

```
bin/console swiftmailer:email:send --from= --to= --subject="Foo" --body="Bar"
```

Choose HTTP client
------------------

[](#choose-http-client)

Mailgun 2.0 is no longer coupled to Guzzle5. Thanks to [Httplug](http://docs.php-http.org/en/latest/index.html) you can now use any library to transport HTTP messages. You can rely on [discovery](http://docs.php-http.org/en/latest/discovery.html) to automatically find an installed client or you can use [HttplugBundle](https://github.com/php-http/HttplugBundle) and provide a client service name to the mailgun configuration.

```
// app/config/config.yml:
cspoo_swiftmailer_mailgun:
    http_client: 'httplug.client'
```

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 56.7% 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 ~174 days

Recently: every ~222 days

Total

10

Last Release

2703d ago

Major Versions

0.4.0 → 1.0.02017-10-21

PHP version history (6 changes)0.1.0PHP &gt;=5.3.2

0.2.0PHP &gt;=5.3

0.3.1PHP ^5.5|^7.0

0.4.0PHP ^5.5 || ^7.0

1.0.0PHP &gt;=7.0.0

1.1.0PHP ^7.0

### Community

Maintainers

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

---

Top Contributors

[![Nyholm](https://avatars.githubusercontent.com/u/1275206?v=4)](https://github.com/Nyholm "Nyholm (34 commits)")[![mapkyca](https://avatars.githubusercontent.com/u/124070?v=4)](https://github.com/mapkyca "mapkyca (8 commits)")[![tehplague](https://avatars.githubusercontent.com/u/1062568?v=4)](https://github.com/tehplague "tehplague (8 commits)")[![tristanbes](https://avatars.githubusercontent.com/u/346010?v=4)](https://github.com/tristanbes "tristanbes (2 commits)")[![jskvara](https://avatars.githubusercontent.com/u/448026?v=4)](https://github.com/jskvara "jskvara (1 commits)")[![mattattui](https://avatars.githubusercontent.com/u/93214?v=4)](https://github.com/mattattui "mattattui (1 commits)")[![rcwsr](https://avatars.githubusercontent.com/u/1541207?v=4)](https://github.com/rcwsr "rcwsr (1 commits)")[![4c0n](https://avatars.githubusercontent.com/u/2325383?v=4)](https://github.com/4c0n "4c0n (1 commits)")[![w10t](https://avatars.githubusercontent.com/u/5654316?v=4)](https://github.com/w10t "w10t (1 commits)")[![drmjo](https://avatars.githubusercontent.com/u/1946791?v=4)](https://github.com/drmjo "drmjo (1 commits)")[![endelwar](https://avatars.githubusercontent.com/u/28512?v=4)](https://github.com/endelwar "endelwar (1 commits)")[![fluchi](https://avatars.githubusercontent.com/u/8443695?v=4)](https://github.com/fluchi "fluchi (1 commits)")

---

Tags

mailgune-mailswiftmailer

### Embed Badge

![Health badge](/badges/mapkyca-swiftmailer-mailgun-transport/health.svg)

```
[![Health](https://phpackages.com/badges/mapkyca-swiftmailer-mailgun-transport/health.svg)](https://phpackages.com/packages/mapkyca-swiftmailer-mailgun-transport)
```

###  Alternatives

[cspoo/swiftmailer-mailgun-bundle

Swiftmailer Mailgun bundle

1031.1M](/packages/cspoo-swiftmailer-mailgun-bundle)[php-flasher/flasher-symfony

Integrate flash notifications into Symfony projects effortlessly with PHPFlasher. Improve user experience and application feedback loops easily.

141.3M20](/packages/php-flasher-flasher-symfony)[azine/mailgunwebhooks-bundle

Symfony2 Bundle to easily capture feedback from mailgun.com via their provided webhooks

104.1k](/packages/azine-mailgunwebhooks-bundle)

PHPackages © 2026

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