Skip to content
The Official Swiftmailer Transport for Postmark.
PHP
Branch: master
Clone or download
Latest commit f3932a6 Jul 7, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src/Postmark Be able to throw exceptions Jun 13, 2019
tests Be able to throw exceptions Jun 13, 2019
.gitignore Ignore vendors and build output. Feb 26, 2015
.travis.yml Update .travis.yml to use correct formatting. Mar 1, 2019
README.md Be able to throw exceptions Jun 13, 2019
composer.json No longer suggest the laravel provider. Jul 20, 2018
composer.lock Upgrade to PHPUnit 6 Feb 6, 2018
phpunit.xml.dist

README.md

swiftmailer-postmark

Build Status

An official Swiftmailer Transport for Postmark.

Send mail through Postmark from your favorite PHP frameworks!

You're just steps away from super simple sending via Postmark:

1. Include this package in your project:
composer require wildbit/swiftmailer-postmark
2. Use the transport to send a message:
<?
//import the transport from the standard composer directory:
require_once('./vendor/autoload.php');

$transport = new \Postmark\Transport('<SERVER_TOKEN>');
$mailer = new Swift_Mailer($transport);

//Instantiate the message you want to send.
$message = (new Swift_Message('Hello from Postmark!'))
  ->setFrom(['john@example.com' => 'John Doe'])
  ->setTo(['jane@example.com'])
  ->setBody('<b>A really important message from our sponsors.</b>', 'text/html')
  ->addPart('Another important message from our sponsors.','text/plain');

//Add some attachment data:
$attachmentData = 'Some attachment data.';
$attachment = new Swift_Attachment($attachmentData, 'my-file.txt', 'application/octet-stream');

$message->attach($attachment);

//Send the message!
$mailer->send($message);

?>
3. Throw exceptions on Postmark api errors
$transport = new \Postmark\Transport('<SERVER_TOKEN>');
$transport->registerPlugin(new \Postmark\ThrowExceptionOnFailurePlugin());

$message = new Swift_Message('Hello from Postmark!');
$mailer->send($message); // Exception is throw when response !== 200

?>
You can’t perform that action at this time.