Class: Sendhub::Rails
- Inherits:
-
Object
- Object
- Sendhub::Rails
- Defined in:
- lib/sendhub/plugins/rails3.rb
Instance Method Summary collapse
- #collect_parts(message) ⇒ Object
- #collect_sendhub_headers(message) ⇒ Object
- #deliver!(message) ⇒ Object
-
#initialize(options) ⇒ Rails
constructor
A new instance of Rails.
Constructor Details
#initialize(options) ⇒ Rails
Returns a new instance of Rails.
3 4 5 6 7 8 9 10 11 |
# File 'lib/sendhub/plugins/rails3.rb', line 3 def initialize() @client = Sendhub::Client.new( :host => [:host], :protocol => [:protocol], :api_key => [:api_key], :secret_key => [:secret_key], :notification_url => [:notification_url] ) end |
Instance Method Details
#collect_parts(message) ⇒ Object
32 33 34 |
# File 'lib/sendhub/plugins/rails3.rb', line 32 def collect_parts() .parts.inject("\n\n\n") {|x, part| x << "--#{.boundary}\n"; x << "#{part.to_s}\n\n"} end |
#collect_sendhub_headers(message) ⇒ Object
36 37 38 |
# File 'lib/sendhub/plugins/rails3.rb', line 36 def collect_sendhub_headers() .header.fields.find_all{|x| x.name =~ /X-SendHub/}.collect{|x| {x.name => x.value}} end |
#deliver!(message) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/sendhub/plugins/rails3.rb', line 13 def deliver!() body = .body body = collect_parts() if .multipart? headers = collect_sendhub_headers() res = @client.send_email( :from => .from, :to => .to, :reply_to => .reply_to, :subject => .subject, :body => body, :content_type => .content_type, :content_transfer_encoding => .content_transfer_encoding, :headers => headers ) puts res.inspect end |