class HttpMailer::Client

Attributes

configuration[R]
mailgun[R]
mandrill[R]
sendgrid[R]

Public Class Methods

new(settings) click to toggle source
# File lib/http_mailer/client.rb, line 5
def initialize(settings)
  configure(settings)
end

Public Instance Methods

configure(settings) click to toggle source
# 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='') click to toggle source
# File lib/http_mailer/client.rb, line 15
def send_message(from, to, subject, body, from_name='', to_name='')
  response = nil

  [sendgrid, mailgun, mandrill].each do |service|
    if service.configured?
      response = service.send_message(from, to, subject, body, to_name, from_name)
      break if response.code == 200
    end
  end

  raise EmailDeliveryError if response.code != 200
  return response
end