Class: Incoming::Strategies::Postmark

Inherits:
Object
  • Object
show all
Includes:
Incoming::Strategy
Defined in:
lib/incoming/strategies/postmark.rb

Instance Attribute Summary

Attributes included from Incoming::Strategy

#message

Instance Method Summary collapse

Methods included from Incoming::Strategy

included

Constructor Details

#initialize(request) ⇒ Postmark

Returns a new instance of Postmark.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/incoming/strategies/postmark.rb', line 9

def initialize(request)
  email = ::Postmark::Mitt.new(request.body.read)

  @attachments = email.attachments

  @message = Mail.new do
    headers email.headers
    from email.from
    to email.to
    reply_to email.reply_to
    subject email.subject

    body email.text_body

    html_part do
      content_type 'text/html; charset=UTF-8'
      body email.html_body
    end if email.html_body

    email.attachments.each do |a|
      add_file :filename => a.file_name, :content => Base64.decode64(a.source['Content'])
    end
  end
end