Skip to content

Instantly share code, notes, and snippets.

@temochka
Created August 2, 2011 06:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save temochka/1119689 to your computer and use it in GitHub Desktop.
Save temochka/1119689 to your computer and use it in GitHub Desktop.
require 'tmail'
require 'postmark'
module Mailer
class PostmarkTransport
attr_accessor :content_type
def initialize(api_key)
Postmark.api_key= api_key
end
def send_message(from, to, subject, body)
raise ArgumentError if to.empty? or from.empty? or subject.empty? or body.empty?
message = TMail::Mail.new
message.from = from
message.to = to
message.subject = subject
message.content_type = content_type
message.body = body
yield(message) if block_given?
#Postmark.send_through_postmark(message)
end
private
def content_type
@content_type ||= 'text/html'
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment