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) ⇒ Array<MultiMail::Message::Postmark>
Transforms the content of Postmark's webhook into a list of messages.
Methods included from Base
included, #initialize, #process, #valid?
Instance Method Details
#spam?(message) ⇒ Boolean
Returns whether the message is spam.
64 65 66 |
# File 'lib/multi_mail/postmark/receiver.rb', line 64 def spam?() ['X-Spam-Status'].value == 'Yes' end |
#transform(params) ⇒ Array<MultiMail::Message::Postmark>
Transforms the content of Postmark's webhook into a list of messages.
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 51 52 53 54 55 56 57 58 59 |
# File 'lib/multi_mail/postmark/receiver.rb', line 11 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)} = Message::Postmark.new do headers headers params['MessageID'] 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. if params.key?('MailboxHash') && !params['MailboxHash'].empty? .mailboxhash = params['MailboxHash'] end if params.key?('MessageID') && !params['MessageID'].empty? . = params['MessageID'] end if params.key?('Tag') && !params['Tag'].empty? .tag = params['Tag'] end [] end |