Class: MailRoom::Delivery::Postback

Inherits:
Object
  • Object
show all
Defined in:
lib/mail_room/delivery/postback.rb

Overview

Postback Delivery method

Author:

  • Tony Pitale

Instance Method Summary collapse

Constructor Details

#initialize(mailbox) ⇒ Postback

Build a new delivery, hold the mailbox configuration

Parameters:



10
11
12
# File 'lib/mail_room/delivery/postback.rb', line 10

def initialize(mailbox)
  @mailbox = mailbox
end

Instance Method Details

#deliver(message) ⇒ Object

deliver the message using Faraday to the configured mailbox url

Parameters:

  • message (String)

    the email message as a string, RFC822 format



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/mail_room/delivery/postback.rb', line 16

def deliver(message)
  connection = Faraday.new
  connection.token_auth @mailbox.delivery_token

  connection.post do |request|
    request.url @mailbox.delivery_url
    request.body = message
    # request.options[:timeout] = 3
    # request.headers['Content-Type'] = 'text/plain'
  end
end