FORGEBOX Enterprise 🚀 - Take your ColdFusion (CFML) Development to Modern Times! Learn More...

Postmark

v1.2.0 Public

Postmark App ColdFusion API


This is a ColdFusion Wrapper written to interact with the Postmark API for transactional emails.

Authors

Developed by Matt Gifford (aka coldfumonkeh)

  • http://www.mattgifford.co.uk
  • http://www.monkehworks.com

Share the love

Got a lot out of this package? Saved you time and money?

Share the love and visit Matt's wishlist: http://www.amazon.co.uk/wishlist/B9PFNDZNH4PY


Requirements

This package requires ColdFusion 9+ or Lucee 4.5+

You will need a valid Postmark account and an associated account token to interact with the API.

Examples

The API wrapper covers all of the methods available within the API. Here's a short sample of what can be achieved:

var oPostmark = new Postmark( accountToken='xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' );

// List servers associated with the account
var servers = oPostmark.listServers();

// Get details on a specific server
var server = oPostmark.getServer( serverId='xxxxxxx' );

// Send an email with attachments
oPostmark.sendEmail(
  serverToken='xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
  From='[email protected]',
  To='[email protected]',
  subject='Your awesome email subject line here',
  TextBody='This is the email email.',
  HtmlBody='<p>This is the email body</p>',
  attachments=[
    '/attachments/test.txt',
    '/attachments/something.png'
  ]
);

// Send batch emails
oPostmark.sendBatchEmails(
  serverToken='xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
  emailData = [
    {
      From='[email protected]',
      To='[email protected]',
      subject='First Batch Email',
      TextBody='This is an email.',
      attachments=[
        '/attachments/test.txt',
        '/attachments/something.png'
      ]
    },
    {
      From='[email protected]',
      To='[email protected]',
      subject='Second Batch Email',
      TextBody='This is an email .'
    }
  ]
);

// Validate a template
oPostmark.validateTemplate(
  servertoken = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
  Subject = "{{##company}}{{name}}{{/company}} {{subjectHeadline}}",
  HtmlBody = "{{##company}}{{address}}{{/company}}{{##each person}} {{name}} {{/each}}",
  TextBody = "{{##company}}{{phone}}{{/company}}{{##each person}} {{name}} {{/each}}",
  TestRenderModel: {
    "userName": "bobby joe"
  }
);

// Send an email using a template
oPostmark.sendEmailWithTemplate(
    serverToken = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
    templateId = 'xxxxxxx',
    TemplateModel = {
      'user_name' = 'John Smith',
      'company' = {
        'name' = 'ACME'
      }
    },
    from = '[email protected]',
    to = '[email protected]'
);

CommandBox Compatible

Installation

This CF wrapper can be installed as standalone or as a ColdBox Module. Either approach requires a simple CommandBox command:

box install postmark

Then follow either the standalone or module instructions below.

Standalone

This wrapper will be installed into a directory called postmark and then can be instantiated via new postmark.Postmark() with the following constructor arguments:

accountToken	=	'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'

ColdBox Module

This package also is a ColdBox module as well. The module can be configured by creating a postmark configuration structure in your application configuration file: config/Coldbox.cfc with the following settings:

postmark = {
  accountToken	=	'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
};

Then you can leverage the CFC via the injection DSL: [email protected]"

Useful Links

  • http://developer.postmarkapp.com/

Here are all the versions for this package. Please note that you can leverage CommandBox package versioning to install any package you like. Please refer to our managing package version guide for more information.

Version Created Last Update Published By Stable Actions
Current
1.2.0 Jul 31 2017 02:25 AM Jul 31 2017 02:25 AM
Version History
1.1.0 May 18 2017 02:38 PM May 18 2017 02:38 PM

 

No collaborators yet.
     
  • May 18 2017 02:38 PM
  • Jul 31 2017 02:25 AM
  • 710
  • 229
  • 37