Skip to content

achrafsoltani/MailgunServiceProvider

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MailgunServiceProvider

A Simple wrapper for the mailgun API for the Silex Framework.

Latest Stable Version Total Downloads License

Features

  • Easy setup.
  • All the Mailgun API features.

Requirements

  • PHP 5.3+
  • mailgun-php

Installation

$ composer require achrafsoltani/mailgunserviceprovider

Setup

require_once __DIR__.'/vendor/autoload.php';

use Silex\Application;
use AchrafSoltani\Provider\MailgunServiceProvider;

$app = new Application();

$app->register(new MailgunServiceProvider(), array(
    'mailgun.api_key' => 'key-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
    'mailgun.domain' => 'domain.tld',
));

// Usage

$app->run();

Usage

  • Example 1 : Sending an email
$message = array(
    'from'    => 'Excited User <[email protected]>',
    'to'      => 'Baz <[email protected]>',
    'subject' => 'Greetings!',
    'text'    => 'Testing some Mailgun awesomness!'    
);

$app['mailgun']->sendMessage($message);
  • Example 2 : Creating a mailing list through the API
$app['mailgun']->post("lists", array(
    'address'     => '[email protected]',
    'description' => 'Mailgun Dev List'
));

Full API documentation

Check how to use the full API capabilities at https://documentation.mailgun.com/user_manual.html