Class: Snails::Mailer::TuktukBackend

Inherits:
Backend
  • Object
show all
Defined in:
lib/snails/mailer.rb

Instance Method Summary collapse

Constructor Details

#initialize(config = {}) ⇒ TuktukBackend

Returns a new instance of TuktukBackend.



170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/snails/mailer.rb', line 170

def initialize(config = {})
  @debug = config[:debug]

  if key = config.dig(:dkim, :private_key) and File.exist?(key)
    config[:dkim][:private_key] = IO.read(key)
  elsif config[:dkim]
    puts "Private key for DKIM not found! Disabling..."
    config.delete(:dkim)
  end

  Tuktuk.options = config
end

Instance Method Details

#deliver(email, options = {}) ⇒ Object



183
184
185
186
187
188
189
190
191
192
# File 'lib/snails/mailer.rb', line 183

def deliver(email, options = {})
  debug = @debug.nil? ? !Snails.env.production? : @debug # if debug isn't set, determine based on env
  resp, email = Tuktuk.deliver(email, debug: debug)

  if resp.is_a?(Tuktuk::Bounce)
    puts "[#{email[:to]}] Email bounced! [#{resp.code}] #{resp.message}"
  end

  return resp, email
end

#deliver_many(emails, options = {}) ⇒ Object



194
195
196
# File 'lib/snails/mailer.rb', line 194

def deliver_many(emails, options = {})
  Tuktuk.deliver_many(emails, options)
end