Class: Hermes::MailgunProvider
- Defined in:
- lib/providers/mailgun/mailgun_provider.rb
Instance Attribute Summary
Attributes inherited from Provider
#credentials, #defaults, #deliverer, #weight
Instance Method Summary collapse
Methods inherited from Provider
#initialize, #message_failure, #message_success, #provider_name, required_credentials
Methods included from Extractors
#complex_extract, #extract_from, #extract_html, #extract_text, #extract_to
Constructor Details
This class inherits a constructor from Hermes::Provider
Instance Method Details
#client ⇒ Object
38 39 40 |
# File 'lib/providers/mailgun/mailgun_provider.rb', line 38 def client Mailgun::Client.new(self.credentials[:api_key]) end |
#mailgun_message(rails_message) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/providers/mailgun/mailgun_provider.rb', line 16 def () = Mailgun::MessageBuilder.new # basics .set_from_address(extract_from()) .add_recipient(:to, extract_to()) .set_subject([:subject]) .set_html_body(extract_html()) .set_text_body(extract_text()) .(.) # optionals .set_from_address('h:reply-to', [:reply_to].formatted.first) if [:reply_to] # and any attachments ..try(:each) do || .(Hermes::EmailAttachment.new()) end return end |
#send_message(rails_message) ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/providers/mailgun/mailgun_provider.rb', line 5 def () domain = .mailgun_domain || self.defaults[:domain] = self.() if self.deliverer.should_deliver? self.client.(domain, ) end self.() end |