class MultiSMTP::Mail

Attributes

default_settings[R]

Public Class Methods

new(default_settings) click to toggle source
# File lib/multi_smtp/mail.rb, line 5
def initialize(default_settings)
  @default_settings = default_settings
end

Public Instance Methods

deliver!(mail) click to toggle source
Calls superclass method
# File lib/multi_smtp/mail.rb, line 9
def deliver!(mail)
  smtp_providers.each_with_index do |smtp_provider, index|
    self.settings = default_settings.merge(smtp_provider)

    begin
      super(mail)
      break
    rescue Exception => e
      next unless all_providers_failed?(index)

      if error_notifier
        error_notifier.notify(mail)
      else
        raise e
      end
    end
  end
end

Private Instance Methods

all_providers_failed?(index) click to toggle source
# File lib/multi_smtp/mail.rb, line 38
def all_providers_failed?(index)
  (smtp_providers.size - 1) == index
end
error_notifier() click to toggle source
# File lib/multi_smtp/mail.rb, line 34
def error_notifier
  @error_notifier ||= MultiSMTP.error_notifier
end
smtp_providers() click to toggle source
# File lib/multi_smtp/mail.rb, line 30
def smtp_providers
  @smtp_providers ||= MultiSMTP.smtp_providers
end