Skip to content

Instantly share code, notes, and snippets.

@tylerodonnell
Last active June 1, 2018 14:15
Show Gist options
  • Save tylerodonnell/e91f7d58293ba037c22d933f8652d022 to your computer and use it in GitHub Desktop.
Save tylerodonnell/e91f7d58293ba037c22d933f8652d022 to your computer and use it in GitHub Desktop.
How to use Postmark SwiftMailer inside Laravel
  1. Install the Postmark Swiftmailer

    composer require wildbit/swiftmailer-postmark
    
  2. Add the following variables to your .env file.

    MAIL_DRIVER=postmark
    POSTMARK_KEY=<key>
    
  3. Add the following line to config/services.php

    'postmark' => [
        'key' => env('POSTMARK_KEY')
    ],
    
  4. Replace Laravel's MailServiceProvider inside config/app.php with the provided PostmarkServiceProvider.php.

    // Illuminate\Mail\MailServiceProvider::class,
    App\Providers\PostmarkServiceProvider::class,
    
<?php
namespace App\Providers;
use Postmark\Transport;
use Illuminate\Mail\MailServiceProvider;
class PostmarkServiceProvider extends MailServiceProvider
{
/**
* Extended register the Swift Transport instance.
*
* @return void
*/
protected function registerSwiftTransport()
{
parent::registerSwiftTransport();
$this->app['swift.transport']->extend('postmark', function($app) {
return new Transport(
config('services.postmark.key')
);
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment