Skip to content
Randy Merrill edited this page Oct 17, 2011 · 4 revisions

This project acts as a simple wrapper for communicating with the Postmark APIs.

Requirements and Support

The postmark4cf project requires a CFML engine that supports full script components such as:

You will also need a Postmark API key from your postmark account

Postmark Usage

Create an instance of the postmark component:

postmark = createObject('component', 'postmark4cf.postmark').init('YOUR POSTMARK API KEY');

To send a message call the addMessage function:

postmark.addMessage({
    "From" : "sender@example.com",
    "To" : "receiver@example.com",
    "Cc" : "copied@example.com",
    "Bcc": "blank-copied@example.com",
    "Subject" : "Test",
    "Tag" : "Invitation",
    "HtmlBody" : "<b>Hello</b>",
    "TextBody" : "Hello",
    "ReplyTo" : "reply@example.com",
    "Headers" : [{ "Name" : "CUSTOM-HEADER", "Value" : "value" }]
});

Since postmark's API is currently setup to handle batches of up to 500 emails at a time the component queues up your messages to be sent in a batch. When you have added all the emails that you would like to send you can send them by calling the `send' function:

results = postmark.send();

The postmark component will automatically split the messages into the batches limited by the threshold (defaults to 500). All results from the batches are combined into a single result and returned from the send function.

Spamcheck Usage

Create an instance of the spamcheck component (can be used as a singleton):

spamcheck = createObject('component', 'postmark4cf.spamcheck').init();

To check the score of an email call the filter function with the raw email body:

results = spamcheck.filter(emailBody);

This returns a struct with the SpamAssassin score in the score key. If you want to obtain the full SpamAssassin report you can request the full report instead:

results = spamcheck.filter(emailBody, 'long');

In addition to the score key this will return the full SpamAssassin report in the report key.

Clone this wiki locally