Ruby gem for sending emails through HTTP API
Pull request Compare This branch is 1 commit ahead, 293 commits behind wildbit:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Postmark Gem

This gem is an official wrapper for Postmark HTTP API ( Use it to send emails and retrieve info about bounces.


gem install postmark

In addition to the postmark gem you also need to install tmail or mail gem. Pick the one you like most:

gem install mail
- or -
gem install tmail

TMail Example

require 'rubygems'
require 'postmark'
require 'tmail'

Postmark.api_key = "your-api-key"

# Make sure you have a sender signature for every From email you specify.
# From can also accept array of addresses.

message              =
message.from         = ""           = "Sheldon Cooper <>"
message.subject      = "Hi Sheldon!"
message.content_type = "text/html"
message.body         = "Hello my friend!"

# You can set customer headers if you like:
message["CUSTOM-HEADER"] = "my custom header value"

# Added a tag:
message.tag = "my-tracking-tag"

# Add attachments:
message.postmark_attachments = ["/path"),"/path")]

# Add attachments with content generated on the fly:
message.postmark_attachments = [{
    "Name" => "September 2011.pdf",
    "Content" => [pdf_content].pack("m"),
    "ContentType" => "application/pdf"

# Or specify a reply-to address (can also be an array of addresses):
message.reply_to = ""


Mail Example

require 'rubygems'
require 'postmark'
require 'mail'
require 'active_support/core_ext'

message =
message.delivery_method(Mail::Postmark, :api_key => "your-api-key")
# ...
# same as in example above
# ...

Other API Features

You can retrieve various information about your server state using the Public bounces API -

# Get delivery stats: (JSON format)

# Get bounces information: (array of bounce objects)

# Find specific bounce by id:
bounce = Postmark::Bounce.find(bounce_id)
bounce.dump     # string, containing raw SMTP data
bounce.activate # reactivate hard bounce


To use SSL encryption when sending email configure the library as follows: = true


The gem relies on TMail or Mail for building the message. You will also need postmark account, server and sender signature set up to use it. If you plan using it in a rails project, check out the postmark-rails gem, which is meant to integrate with ActionMailer.

The plugin will try to use ActiveSupport Json if it is already included. If not, it will attempt using the built-in ruby Json library. You can also explicitly specify which one to be used, using

Postmark.response_parser_class = :Json # :ActiveSupport or :Yajl is also supported.

Note on Patches/Pull Requests

  • Fork the project.

  • Make your feature addition or bug fix.

  • Add tests for it. This is important so I don't break it in a future version unintentionally.

  • Commit, do not mess with rakefile, version, or history.

  • Send me a pull request. Bonus points for topic branches.

Authors & Contributors

  • Petyo Ivanov

  • Ilya Sabanin

  • Hristo Deshev

  • Artem Chistyakov

  • Dmitry Sabanin

  • Randy Schmidt

  • Chris Williams

  • Aitor García Rey

  • James Miller

  • Yury Batenko

  • Pavel Maksimenko

  • Anton Astashov

  • Marcus Brito

  • Tyler Hunt


Copyright © 2012 Wildbit LLC. See LICENSE for details.