Created
June 4, 2014 18:01
-
-
Save tadman/d20db52f1ec2021cf9d3 to your computer and use it in GitHub Desktop.
PostageApp Delivery System for use with Devise
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
config.action_mailer.delivery_method = :postageapp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require_relative '../../lib/postageapp_delivery.rb' | |
PostageApp.configure do |config| | |
config.api_key = 'YOUR_API_KEY' | |
end | |
ActionMailer::Base.add_delivery_method :postageapp, PostageAppDelivery |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PostageAppDelivery | |
def initialize(opts) | |
# noop | |
end | |
def deliver!(mail) | |
request = PostageApp::Request.new(:send_message, { | |
'headers' => { | |
'from' => mail.from, | |
'subject' => mail.subject | |
}, | |
'recipients' => mail.to, | |
'content' => { | |
'text/html' => mail.body.to_s | |
} | |
}) | |
response = request.send | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment