Mailgun integration for SilverStripe emails
PHP
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
_config
src
tests
.editorconfig
.gitattributes
.scrutinizer.yml
.travis.yml
LICENSE.md
README.md
composer.json

README.md

SilverStripe Mailgunner

Build Status Code Quality Code Coverage Version License

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

Installation:

$ composer require kinglozzer/silverstripe-mailgunner:^1.0

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: 'bin.mailgun.net'
  api_ssl: false
  api_version: '8932206e'

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 = '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:

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

<?php

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