Class: MultiMail::Message::Mandrill
- Defined in:
- lib/multi_mail/mandrill/message.rb
Overview
Instance Attribute Summary collapse
-
#dkim_signed ⇒ Object
Returns the value of attribute dkim_signed.
-
#dkim_valid ⇒ Object
Returns the value of attribute dkim_valid.
-
#email ⇒ Object
Returns the value of attribute email.
-
#spam_report_score ⇒ Object
Returns the value of attribute spam_report_score.
-
#spf_result ⇒ Object
Returns the value of attribute spf_result.
-
#ts ⇒ Object
Returns the value of attribute ts.
Instance Method Summary collapse
-
#mandrill_attachments ⇒ Array<Faraday::UploadIO>
Returns the message's attachments in Mandrill format.
-
#mandrill_headers ⇒ Hash
Returns the message headers in Mandrill format.
-
#mandrill_to ⇒ Array<Hash>
Returns the To header in Mandrill format.
-
#to_mandrill_hash ⇒ Hash
Returns the message as parameters to POST to Mandrill.
Constructor Details
This class inherits a constructor from MultiMail::Message::Base
Instance Attribute Details
#dkim_signed ⇒ Object
Returns the value of attribute dkim_signed.
5 6 7 |
# File 'lib/multi_mail/mandrill/message.rb', line 5 def dkim_signed @dkim_signed end |
#dkim_valid ⇒ Object
Returns the value of attribute dkim_valid.
5 6 7 |
# File 'lib/multi_mail/mandrill/message.rb', line 5 def dkim_valid @dkim_valid end |
#email ⇒ Object
Returns the value of attribute email.
5 6 7 |
# File 'lib/multi_mail/mandrill/message.rb', line 5 def email @email end |
#spam_report_score ⇒ Object
Returns the value of attribute spam_report_score.
5 6 7 |
# File 'lib/multi_mail/mandrill/message.rb', line 5 def spam_report_score @spam_report_score end |
#spf_result ⇒ Object
Returns the value of attribute spf_result.
5 6 7 |
# File 'lib/multi_mail/mandrill/message.rb', line 5 def spf_result @spf_result end |
#ts ⇒ Object
Returns the value of attribute ts.
5 6 7 |
# File 'lib/multi_mail/mandrill/message.rb', line 5 def ts @ts end |
Instance Method Details
#mandrill_attachments ⇒ Array<Faraday::UploadIO>
Returns the message's attachments in Mandrill format.
42 43 44 45 46 47 48 49 50 |
# File 'lib/multi_mail/mandrill/message.rb', line 42 def .map do || { 'type' => .content_type, 'name' => .filename, 'content' => Base64.encode64(.body.decoded) } end end |
#mandrill_headers ⇒ Hash
Returns the message headers in Mandrill format.
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/multi_mail/mandrill/message.rb', line 26 def mandrill_headers hash = {} header_fields.each do |field| key = field.name.downcase # Mandrill only allows Reply-To and X-* headers currently. # https://mandrillapp.com/api/docs/messages.ruby.html if key == 'reply-to' || key.start_with?('x-') hash[field.name] = field.value end end hash end |
#mandrill_to ⇒ Array<Hash>
Returns the To header in Mandrill format.
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/multi_mail/mandrill/message.rb', line 10 def mandrill_to if to to.each_with_index.map do |value,index| { 'email' => value, 'name' => self[:to].display_names[index] } end else [] end end |
#to_mandrill_hash ⇒ Hash
Returns the message as parameters to POST to Mandrill.
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/multi_mail/mandrill/message.rb', line 55 def to_mandrill_hash images, = .partition do || ['type'].start_with?('image/') end hash = { 'html' => body_html, 'text' => body_text, 'subject' => subject, 'from_email' => from && from.first, 'from_name' => from && self[:from].display_names.first, 'to' => mandrill_to, 'headers' => mandrill_headers, 'attachments' => , 'images' => images, 'tags' => , } normalize(hash) end |