-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New PostmarkServiceProvider for Laravel 5
- Loading branch information
1 parent
5b3ac91
commit c837816
Showing
4 changed files
with
51 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,27 @@ | ||
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: | ||
|
||
Illuminate\Mail\MailServiceProvider | ||
|
||
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. | ||
|
||
'postmark' => [ | ||
'api_key' => '' | ||
], | ||
|
||
|
||
Run a composer update and you are ready to go! |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
namespace Snowfire\Mail; | ||
|
||
use Openbuildings\Postmark\Swift_PostmarkTransport; | ||
use Swift_Mailer; | ||
|
||
class PostmarkServiceProvider extends \Illuminate\Mail\MailServiceProvider { | ||
|
||
/** | ||
* Register the Swift Mailer instance. | ||
* | ||
* @param array $config | ||
* @return void | ||
* | ||
* @throws \InvalidArgumentException | ||
*/ | ||
public function registerSwiftMailer() | ||
{ | ||
if ($this->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']) | ||
); | ||
}); | ||
} | ||
|
||
} |