Postmark

Overview

Integration

User guide

API reference

Webhooks

Official libraries

These libraries are maintained by the developers at Postmark and are the easiest way to integrate Postmark with your application.

Don’t see the library you’re looking for?

If you can’t find the right library, check out our Community Libraries. If you’re looking for code to use with Postmark Inbound try our email parse code examples.

We’re building a wishlist of Postmark plugins, libraries, and integrations. If you have something you’d like to see, or would like to contribute, let us know!

Rails gem

Configuring your Rails application

You will need the postmark-rails gem for drop-in integration with ActionMailer.

Don’t forget to run the bundle install command every time you change something in your Gemfile.

The postmark_settings hash can contain all options supported by Postmark::ApiClient.

Add this to your gemfile

gem 'postmark-rails'

Add this to your config/application.rb file:

config.action_mailer.delivery_method = :postmark
config.action_mailer.postmark_settings = { :api_key => "server token" }

Send a single email

Here’s a simple example of how to send a single HTML email with open tracking enabled. Take a look at the README for more examples.

Example request

class TestMailer < ActionMailer::Base
  def message
    mail(
      :subject => 'hello',
      :to  => 'ohn.doe@yahoo.comj',
      :from => 'john.snow@yahoo.com',
      :html_body => '<strong>Hello John Doe<strong>',
      :track_opens => 'true'
    )
  end
end

Ruby gem

Configuring your ruby application

You will need the postmark gem to get started.

If you’re using Bundler, don't forget to run the bundle install command every time you change something in your Gemfile.

Install with Bundler

gem 'postmark'

Create an instance of Postmark::ApiClient

client = Postmark::ApiClient.new('server token')

Send a single email

Here’s a simple example of how to send a single HTML email with open tracking enabled. Take a look at the README for more examples.

Example request

client.deliver(
  from: 'john.snow@yahoo.com',
  to: 'john.doe@yahoo.com',
  subject: 'hello',
  html_body: '<strong>Hello John Doe<strong>',
  track_opens: true
)

.NET

Installation

The Postmark.NET NuGet package makes it easier to use the Postmark API from your .NET 2, 3.x, and 4.x projects without having to build your own API calls.

Install with NuGet

PM> Install-Package Postmark

Import

using PostmarkDotNet;

Send a single email

Here’s a simple example of how to send a single HTML email with open tracking enabled. Take a look at the wiki for more examples.

Example request

PostmarkMessage message = new PostmarkMessage
{
    From = "sender@example.com",
    To = "receiver@example.com",
    Subject = "Test",
    HtmlBody = "Hello",
    TextBody = "Hello",
    ReplyTo = "reply@example.com",
    TrackOpens = true,
    Headers = new NameValueCollection {{"CUSTOM-HEADER", "value"}}
};

PostmarkClient client = new PostmarkClient("server token");

PostmarkResponse response = client.SendMessage(message);

if(response.Status != PostmarkStatus.Success)
{
    Console.WriteLine("Response was: " + response.Message);
}

WordPress plugin