Skip to content

Latest commit

 

History

History
100 lines (70 loc) · 1.81 KB

index.md

File metadata and controls

100 lines (70 loc) · 1.81 KB

AxeleroMailgunBundle

  1. Installation
  2. Configuration
  3. Usage

1. Installation

Run from terminal:

$ composer require axelero/axelero-mailgun-bundle

Enable bundle in the kernel:

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Axelero\MailgunBundle\AxeleroMailgunBundle()

    );
}

2. Configuration

Add following lines in your configuration:

# app/config/config.yml

axelero_mailgun:
  domain: 'your-domain'
  api_key: 'your-api-key'
# app/config/config_dev.yml

axelero_mailgun:
  domain: 'your-sandbox-domain'
  api_key: 'your-sandbox-api-key'

Otherwise the default value post will be used.

3. Usage

Example:

    ...
    //collecting the recipients
    $recipients = [
        [
            'email' => '[email protected]',
            'first' => 'firstName',
            'last' => 'lastName'
        ],
        [
            'email' => '[email protected]',
            'first' => 'anotherName',
            'last' => 'anotherSurname',
            'myCustomData' => 'customValue',
            'anotherCustom' => ['my', 'data'],
        ],
    ];

For myCustomData see [https://github.com/mailgun/mailgun-php/blob/v1.8/src/Mailgun/Messages/README.md]

By default you can send mails with the account configured in your config.yml

    

    $this->get("axelero_mailgun.gunman")
    ->batchSend('[email protected]', 'mailTitle', '<h1>Your Content</h1>', $recipients);

Otherwise you can configure api parameters at runtime

    $this->get("axelero_mailgun.gunman")
    ->setKey($key)
    ->setDomain($domain)
    ->batchSend('[email protected]', 'mailTitle', '<h1>Your Content</h1>', $recipients);