Mailgun integration for SilverStripe emails

Installs: 12 380

Dependents: 0

Suggesters: 0

Security: 0

Stars: 7

Watchers: 3

Forks: 7

Open Issues: 1


3.1.1 2018-05-18 13:02 UTC

This package is auto-updated.

Last update: 2024-05-04 22:03:17 UTC


Build Status Code Quality Code Coverage Version License

A SilverStripe Mailer class to send emails via the Mailgun API.


$ 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.


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

After: 'silverstripe-mailgun'
  api_domain: ''
  api_key: 'key-3ax6xnjp29jd6fds4gc373sgvjxteol0'
After: 'silverstripe-mailgun'
  environment: 'dev'
# Get your own Postbin ID by visiting
  api_endpoint: ''
  debug: true

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

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 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 = '',
	$to = ',',
	$subject = 'My awesome email',
	$content = 'Hello world!'

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

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:


Email::set_mailer(new Kinglozzer\SilverStripeMailgunner\Mailer);