PHPackages                             kinglozzer/silverstripe-mailgunner - 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. kinglozzer/silverstripe-mailgunner

ActiveSilverstripe-module[Mail &amp; Notifications](/categories/mail)

kinglozzer/silverstripe-mailgunner
==================================

Mailgun integration for SilverStripe emails

3.1.1(8y ago)712.5k6[1 issues](https://github.com/kinglozzer/silverstripe-mailgunner/issues)BSD-3-ClausePHP

Since Feb 27Pushed 8y ago1 watchersCompare

[ Source](https://github.com/kinglozzer/silverstripe-mailgunner)[ Packagist](https://packagist.org/packages/kinglozzer/silverstripe-mailgunner)[ Docs](https://github.com/kinglozzer/silverstripe-mailgunner)[ RSS](/packages/kinglozzer-silverstripe-mailgunner/feed)WikiDiscussions master Synced today

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

SilverStripe Mailgunner
=======================

[](#silverstripe-mailgunner)

[![Build Status](https://camo.githubusercontent.com/981a279a3444e514d30c31615247a3cc76423124594aac2e7bbe8141ebc96777/687474703a2f2f696d672e736869656c64732e696f2f7472617669732f6b696e676c6f7a7a65722f73696c7665727374726970652d6d61696c67756e6e65722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/kinglozzer/silverstripe-mailgunner)[![Code Quality](https://camo.githubusercontent.com/f7771116314009c45f1645dfc82da617332fe5b91f7c7620ae83a924eccf4724/687474703a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6b696e676c6f7a7a65722f73696c7665727374726970652d6d61696c67756e6e65722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/kinglozzer/silverstripe-mailgunner)[![Code Coverage](https://camo.githubusercontent.com/43786ff69ee9f76764bdb8820ef0ee4f72af17c4e47b1c585f1fad3285cf8f90/687474703a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6b696e676c6f7a7a65722f73696c7665727374726970652d6d61696c67756e6e65722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/kinglozzer/silverstripe-mailgunner)[![Version](https://camo.githubusercontent.com/18f6b44c459be9f1247ddc4db745d60fafbdcc26c879f14b1f3fe99a6a3c44e4/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6b696e676c6f7a7a65722f73696c7665727374726970652d6d61696c67756e6e65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/kinglozzer/silverstripe-mailgunner)[![License](https://camo.githubusercontent.com/3492bbd48f7db164b193e20fb22c2140787923f3ea8a2bd192433df81834d9c7/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6b696e676c6f7a7a65722f73696c7665727374726970652d6d61696c67756e6e65722e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)

A SilverStripe `Mailer` class to send emails via the [Mailgun](https://www.mailgun.com/) API.

Installation:
-------------

[](#installation)

```
$ composer require kinglozzer/silverstripe-mailgunner:^3.0 php-http/curl-client guzzlehttp/psr7
```

Note that the Mailgun PHP library uses HTTPlug, so you can switch out the HTTP adapter for another one if you desire. More info is available [here](http://docs.php-http.org/en/latest/httplug/users.html).

Configuration:
--------------

[](#configuration)

Set your API key and domain name via the `Config` API:

```
---
After: 'silverstripe-mailgun'
---
Kinglozzer\SilverStripeMailgunner\Mailer:
  api_domain: 'samples.mailgun.org'
  api_key: 'key-3ax6xnjp29jd6fds4gc373sgvjxteol0'
---
After: 'silverstripe-mailgun'
Only:
  environment: 'dev'
---
# Get your own Postbin ID by visiting http://bin.mailgun.net
Kinglozzer\SilverStripeMailgunner\Mailer:
  api_endpoint: 'http://bin.mailgun.net/62e69d41'
  debug: true
```

**Note**: make sure that you always provide a “from” address, and/or have set the `Email.admin_email` configuration value.

Batch messages:
---------------

[](#batch-messages)

You can send an email to a group of recipients via a single API call (without using Cc or Bcc) using Mailgun’s [batch sending](https://documentation.mailgun.com/user_manual.html#batch-sending) functionality. This tells Mailgun to send each recipient an email with only their name in the `to` field. Not using this functionality would result in *all* recipients’ email addresses being displayed in the `to` field.

To send a batch email, simply pass all the email addresses you want to send to as the `to` field, and add an `X-Mailgunner-Batch-Message` header:

```
$email = Email::create(
	$from = 'noreply@example.com',
	$to = 'user1@example.com, user2@example.com',
	$subject = 'My awesome email',
	$content = 'Hello world!'
);

$email->addCustomHeader('X-Mailgunner-Batch-Message', true);
$email->send();
```

SilverStripe version compatiblity:
----------------------------------

[](#silverstripe-version-compatiblity)

This module has only been tested with SilverStripe 3.2+, but should work with previous versions. In older versions of SilverStripe, you will need to specify the `Mailer` implementation to use in `_config.php`:

```
