Skip to content
Postmark plugin for CakePHP
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Postmark plugin for CakePHP

CakePHP plugin that makes email delivery using Postmark


Written for CakePHP 2.x


Copyright (c) 2011 Maury M. Marques


You can install this plugin using Composer, GIT Submodule, GIT Clone or Manually

[Using Composer]

Add the plugin to your project's composer.json - something like this:

  "require": {
    "maurymmarques/postmark-plugin": "dev-master"
  "extra": {
    "installer-paths": {
      "app/Plugin/Postmark": ["maurymmarques/postmark-plugin"]

Then just run composer install

Because this plugin has the type cakephp-plugin set in it's own composer.json, composer knows to install it inside your /Plugin directory, rather than in the usual vendors file.

[GIT Submodule]

In your app directory (app/Plugin) type:

git submodule add git:// Plugin/Postmark
git submodule init
git submodule update

[GIT Clone]

In your plugin directory (app/Plugin or plugins) type:

git clone Postmark


  • Download the Postmark archive.
  • Unzip that download.
  • Rename the resulting folder to Postmark
  • Then copy this folder into app/Plugin/ or plugins


Bootstrap the plugin in app/Config/bootstrap.php:


Create the file app/Config/email.php with the class EmailConfig.

class EmailConfig {
	public $postmark = array(
		'transport' => 'Postmark.Postmark',
		'uri' => '',
		'key' => 'your-postmark-key',
		'track_opens' => true

If you want your connection to Postmark to be encrypted, simply change the uri to use https.

You can set track_opens to false or remove it from the config array if you don't want Postmark to track emails. Read more about Open Tracking.

Note: Make sure to modified the API key to match the credentials for your Postmark server rack instance.


You can also configure a proxy in the file app/Config/email.php:

class EmailConfig {
  public $postmark = array(
    'transport' => 'Postmark.Postmark',
    'uri' => '',
    'key' => 'your-postmark-key',
    'track_opens' => true,
    'proxy' => array(
      'host' => 'your-proxy-host', # Can be an array with settings to authentication class
      'port' => 3128, # Default 3128
      'method' => null, # Proxy method (ie, Basic, Digest). If empty, disable proxy authentication
      'user' => null, # Username if your proxy need authentication
      'pass' => null # Password to proxy authentication

Read more about HttpSocket Parameters.


This plugin uses CakeEmail, and works virtually the same.

Then, simply send messages like this:

App::uses('CakeEmail', 'Network/Email');
$email = new CakeEmail();

$email->subject('Test Postmark');

Or use more resources:

App::uses('CakeEmail', 'Network/Email');
$email = new CakeEmail();

$email->template('default', 'default');
$email->viewVars(array('name' => 'Your Name'));
$email->from(array('' => 'Your Name'));
$email->to(array('' => 'Recipient1', '' => 'Recipient2'));
$email->cc(array('' => 'Recipient3', '' => 'Recipient4'));
$email->bcc(array('' => 'Recipient5', '' => 'Recipient6'));
$email->subject('Test Postmark');
$email->addHeaders(array('Tag' => 'my tag'));
    'cake.icon.png' => array(
        'file' => WWW_ROOT . 'img' . DS . 'cake.icon.png'


If you need the instance of the class PostmarkTrasport:

App::uses('CakeEmail', 'Network/Email');
$email = new CakeEmail();

$postmarkInstance = $email->transport('Postmark.Postmark')->transportClass();

The syntax of all parameters is the same as the default CakeEmail:

For more information, see the Postmark API documentation:


You can see the response from Postmark in the return value when you send a message:

$result = $email->send('Message');
$this->log($result, 'debug');

If there are any errors, they'll be included in the response. See the Postmark API documentation for error code detail:

CakePHP 1.3+

This class does not work for CakePHP 1.3, for this see:

You can’t perform that action at this time.