Skip to content

Commit

Permalink
New PostmarkServiceProvider for Laravel 5
Browse files Browse the repository at this point in the history
  • Loading branch information
emilsundberg committed Aug 1, 2015
1 parent 5b3ac91 commit c837816
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 62 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -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
Expand Down
15 changes: 7 additions & 8 deletions README.md
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!
53 changes: 0 additions & 53 deletions src/Snowfire/Mail/MailServiceProvider.php

This file was deleted.

43 changes: 43 additions & 0 deletions src/Snowfire/Mail/PostmarkServiceProvider.php
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'])
);
});
}

}

0 comments on commit c837816

Please sign in to comment.