Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Ruby gem for sending emails through http://postmarkapp.com HTTP API

tag: v0.9.5

Fetching latest commit…

Cannot retrieve the latest commit at this time

README.rdoc

Postmark gem

Ruby gem for sending emails through postmarkapp.com HTTP API

Install

sudo gem install postmark

Example

#!/usr/bin/env ruby

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              = TMail::Mail.new
message.from         = "leonard@bigbangtheory.com"
message.to           = "Sheldon Cooper <sheldon@bigbangtheory.com>"
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 = [File.open("/path"), File.open("/path")]

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

Postmark.send_through_postmark(message)

If you are using the Mail gem, you can also use Postmark as a delivery method like:

message = Mail.new
message.delivery_method Mail::Postmark, {:api_key => "your-api-key"}
message.deliver

You can retrieve various information about your server state using the Public bounces API - developer.postmarkapp.com/bounces

# Get delivery stats: (JSON format)
Postmark.delivery_stats

# Get bounces information: (array of bounce objects)    
Postmark::Bounce.all

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

Encryption

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

Postmark.secure = true

Requirements

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

  • Randy Schmidt

  • Chris Williams

  • Aitor García Rey

Copyright

Copyright © 2010 Wildbit LLC. See LICENSE for details.

Something went wrong with that request. Please try again.