Skip to content

Instantly share code, notes, and snippets.

@sergiors
Created June 20, 2016 15:05
Show Gist options
  • Save sergiors/99f6008bbe1cda427139acfcfb322909 to your computer and use it in GitHub Desktop.
Save sergiors/99f6008bbe1cda427139acfcfb322909 to your computer and use it in GitHub Desktop.

composer require mailgun/mailgun-php

// ...

$app->register(new MailgunServiceProvider());

$app['mailgun.options'] = [
    'api_key' => '',
    'domain' => ''
];

$app['mailgun']->sendMessage($app['mailgun.options']['domain'], [
    'from' => '',
    'to'  => '',
    'subject' => '',
    'text' => ''
]);
<?php
namespace Sergiors\Sergiors\Silex\Provider;
use Silex\Application;
use Silex\ServiceProviderInterface;
use Mailgun\Mailgun;
//use Pimple/Container;
//use Pimple/ServiceProviderInterface;
class MailgunServiceProvider implements ServiceProviderInterface
{
//public function register(Container $app)
public function register(Application $app)
{
$app['mailgun'] = $app->share(function (Application $app) {
return new Mailgun($app['mailgun.options']['api_key']);
});
$app['mailgun.options'] = [
'api_key' => null,
'domain' => null
];
}
public function boot(Application $app)
{
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment