Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: b84e530c64
Fetching contributors…

Cannot retrieve contributors at this time

file 72 lines (52 sloc) 2.261 kb

Postmark Mitt

This gem provides a little wrapper object for taking JSON from Postmark's incoming email system and composing it back into an object resembling an email. This comes in handy when you are trying to figure out what to do with the email.

Postmark-mitt has been verified to work on Ruby Enterprise Edition 1.8.7, 1.9.2 and 1.9.3.


gem install postmark-mitt


require 'lib/postmark_mitt'

# if you are just playing with this library
email ="path/to/json/file/in/spec/fixtures"))

# if you are doing this in a controller
email = # ""
email.from # Bob Bobson <>
email.from_email #
email.headers # returns a hash of the headers

email.attachments # array of attachment objects

attachment = email.attachments.first
attachment.content_type # will base64 decode the content... eventually this will lazy-load the file from Postmark
attachment.size # NYI
# You get the idea

A lot of times you want to do something with the email, like create a post

mitt =

class Post
  def self.create_from_postmark(mitt)
    author = User.find_by_api_email(
    handle_no_author # send an email back saying we couldn't find them
    post = new
    post.title = mitt.subject = author =
    post.message_id = mitt.message_id # Make sure we don't process the same email twice
    # You get the idea, right?

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

  • Randy Schmidt


Copyright © 2011 Randy Schmidt. See LICENSE for details.

Something went wrong with that request. Please try again.