diff --git a/LICENSE b/LICENSE index 69e8741..1b85e92 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2014 Snowfire +Copyright (c) 2015 Snowfire Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index ee78e9f..73850be 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,12 @@ -Send emails in Laravel 4 with Postmark +Send emails in Laravel with Postmark ==================================== -[Postmarkapp](http://postmarkapp.com) is an excellent ESP (Email Service Provider). This package makes it possible to send your emails with Postmark without modifing your code. Please note that this package is for Laravel 4 and **does not** work in Laravel 5. +[Postmarkapp](http://postmarkapp.com) is an excellent ESP (Email Service Provider). This package makes it possible to send your emails with Postmark without modifing your code. + +Using Laravel 4? Visit the [`laravel-4` branch](Snowfire/Laravel-Postmark-Driver/tree/laravel-4) Add this to your `composer.json` - "snowfire/mail": "dev-master" + "snowfire/mail": "2.*" Open app.php and **remove** this line: @@ -12,11 +14,9 @@ Open app.php and **remove** this line: Add - Snowfire\Mail\MailServiceProvider - -In your config file `mail.php` change your driver to postmark. + Snowfire\Mail\PostmarkServiceProvider - 'driver' => 'postmark' +In your `.env` change your driver to postmark. In your config file `services.php` add your postmark api key. @@ -24,5 +24,4 @@ In your config file `services.php` add your postmark api key. 'api_key' => '' ], - Run a composer update and you are ready to go! diff --git a/src/Snowfire/Mail/MailServiceProvider.php b/src/Snowfire/Mail/MailServiceProvider.php deleted file mode 100644 index e7fb81a..0000000 --- a/src/Snowfire/Mail/MailServiceProvider.php +++ /dev/null @@ -1,53 +0,0 @@ -package('snowfire/mail'); - } - - /** - * Register the Swift Transport instance. - * - * @param array $config - * @return void - * - * @throws \InvalidArgumentException - */ - protected function registerSwiftTransport($config) - { - if ($config['driver'] == 'postmark') - { - $this->registerPostmarkTransport($config); - } - else - { - parent::registerSwiftTransport($config); - } - } - - /** - * Register the Postmark Swift Transport instance. - * - * @param array $config - * @return void - */ - protected function registerPostmarkTransport($config) - { - $postmark = $this->app['config']->get('services.postmark', []); - - $this->app->bindShared('swift.transport', function() use ($postmark) - { - return new Swift_PostmarkTransport($postmark['api_key']); - }); - } - -} diff --git a/src/Snowfire/Mail/PostmarkServiceProvider.php b/src/Snowfire/Mail/PostmarkServiceProvider.php new file mode 100644 index 0000000..b6c4e9a --- /dev/null +++ b/src/Snowfire/Mail/PostmarkServiceProvider.php @@ -0,0 +1,43 @@ +app['config']->get('mail.driver') == 'postmark') { + $this->registerPostmarkMailer(); + } else { + parent::registerSwiftMailer(); + } + } + + /** + * Register the Postmark Swift Mailer. + * + * @return void + */ + protected function registerPostmarkMailer() + { + $postmark = $this->app['config']->get('services.postmark', []); + + $this->app['swift.mailer'] = $this->app->share(function ($app) use ($postmark) { + return new Swift_Mailer( + new Swift_PostmarkTransport($postmark['api_key']) + ); + }); + } + +} \ No newline at end of file