Class: HttpMailer::Client
- Inherits:
-
Object
- Object
- HttpMailer::Client
- Defined in:
- lib/http_mailer/client.rb
Instance Attribute Summary collapse
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
-
#mailgun ⇒ Object
readonly
Returns the value of attribute mailgun.
-
#mandrill ⇒ Object
readonly
Returns the value of attribute mandrill.
-
#sendgrid ⇒ Object
readonly
Returns the value of attribute sendgrid.
Instance Method Summary collapse
- #configure(settings) ⇒ Object
-
#initialize(settings) ⇒ Client
constructor
A new instance of Client.
- #send_message(from, to, subject, body, from_name = '', to_name = '') ⇒ Object
Constructor Details
#initialize(settings) ⇒ Client
Returns a new instance of Client.
5 6 7 |
# File 'lib/http_mailer/client.rb', line 5 def initialize(settings) configure(settings) end |
Instance Attribute Details
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
3 4 5 |
# File 'lib/http_mailer/client.rb', line 3 def configuration @configuration end |
#mailgun ⇒ Object (readonly)
Returns the value of attribute mailgun.
3 4 5 |
# File 'lib/http_mailer/client.rb', line 3 def mailgun @mailgun end |
#mandrill ⇒ Object (readonly)
Returns the value of attribute mandrill.
3 4 5 |
# File 'lib/http_mailer/client.rb', line 3 def mandrill @mandrill end |
#sendgrid ⇒ Object (readonly)
Returns the value of attribute sendgrid.
3 4 5 |
# File 'lib/http_mailer/client.rb', line 3 def sendgrid @sendgrid end |
Instance Method Details
#configure(settings) ⇒ Object
9 10 11 12 13 |
# File 'lib/http_mailer/client.rb', line 9 def configure(settings) @mailgun = MailgunServiceHandler.new(settings[:mailgun]) @sendgrid = SendGridServiceHandler.new(settings[:sendgrid]) @mandrill = MandrillServiceHandler.new(settings[:mandrill]) end |
#send_message(from, to, subject, body, from_name = '', to_name = '') ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/http_mailer/client.rb', line 15 def (from, to, subject, body, from_name='', to_name='') response = nil [sendgrid, mailgun, mandrill].each do |service| if service.configured? response = service.(from, to, subject, body, to_name, from_name) break if response.code == 200 end end raise EmailDeliveryError if response.code != 200 return response end |