Class: ScalewayTem::ActionMailer::DeliveryMethod

Inherits:
Object
  • Object
show all
Defined in:
lib/scaleway_tem/action_mailer/delivery_method.rb

Overview

The ActionMailer delivery method interface, which is just two methods: a constructor taking the settings hash and #deliver! taking the built Mail::Message.

Registered as :scaleway_tem by the Railtie, so an application selects it with config.action_mailer.delivery_method = :scaleway_tem and needs no initializer of its own beyond supplying credentials.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(settings = {}) ⇒ DeliveryMethod

Returns a new instance of DeliveryMethod.



15
16
17
# File 'lib/scaleway_tem/action_mailer/delivery_method.rb', line 15

def initialize(settings = {})
  @settings = settings || {}
end

Instance Attribute Details

#settingsObject (readonly)

Returns the value of attribute settings.



13
14
15
# File 'lib/scaleway_tem/action_mailer/delivery_method.rb', line 13

def settings
  @settings
end

Instance Method Details

#deliver!(mail) ⇒ Object

Raises on failure rather than swallowing, so ActionMailer surfaces a delivery problem the same way the SMTP method does. An application that would rather not have a failed email take down a request should set config.action_mailer.raise_delivery_errors = false, which is Rails' own switch for exactly this, instead of the gem inventing a second one.



24
25
26
27
# File 'lib/scaleway_tem/action_mailer/delivery_method.rb', line 24

def deliver!(mail)
  payload = MessageMapper.call(mail, project_id: project_id)
  client.send_email(payload)
end