Class: MultiMail::Receiver::Postmark
- Inherits:
-
Object
- Object
- MultiMail::Receiver::Postmark
- Includes:
- Base
- Defined in:
- lib/multi_mail/postmark/receiver.rb
Overview
Postmark's incoming email receiver.
Instance Method Summary collapse
-
#spam?(message) ⇒ Boolean
Whether the message is spam.
- #transform(params) ⇒ Object
Methods included from Base
#initialize, #process, #valid?
Instance Method Details
#spam?(message) ⇒ Boolean
Returns whether the message is spam.
55 56 57 |
# File 'lib/multi_mail/postmark/receiver.rb', line 55 def spam?() ['X-Spam-Status'].value == 'Yes' end |
#transform(params) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/multi_mail/postmark/receiver.rb', line 7 def transform(params) headers = Multimap.new params['Headers'].each do |header| headers[header['Name']] = header['Value'] end # Due to scoping issues, we can't call `transform_address` within `Mail.new`. from = transform_address(params['FromFull']) to = params['ToFull'].map{|hash| transform_address(hash)} cc = params['CcFull'].map{|hash| transform_address(hash)} = Mail.new do headers headers from from to to cc cc reply_to params['ReplyTo'] subject params['Subject'] date params['Date'] text_part do body params['TextBody'] end html_part do content_type 'text/html; charset=UTF-8' body CGI.unescapeHTML(params['HtmlBody']) end params['Attachments'].each do || add_file(:filename => ['Name'], :content => Base64.decode64(['Content'])) end end # Extra Postmark parameters. %w(MailboxHash MessageID Tag).each do |key| if params.key?(key) && !params[key].empty? [key] = params[key] end end [] end |