Module: ContainerConfig::Rails::Mailer

Defined in:
lib/container_config/rails/mailer.rb

Overview

Rails ActionMailer config module

Class Method Summary collapse

Class Method Details

.load(key, **options) ⇒ Hash

loads Rails ActionMailer configuration settings from environment variables, mounted secrets, or the application credentials

Parameters:

  • key (String)

    base key for the Mailer config (“MAILER”)

  • options (Hash)

    Options Hash

Options Hash (**options):

  • :required (Boolean)

    whether to raise an exception if the settings cannot be found

  • :secret_mount_directory (String)

    directory where secret files are mounted

Returns:

  • (Hash)

    Mailer configuration hash with :perform_deliveries, :perform_caching, :raise_delivery_errors, :delivery_method, :sendmail_settings, and :smtp_settings keys



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/container_config/rails/mailer.rb', line 20

def self.load(key, **options)
  mail_config = {}

  mail_config[:perform_deliveries] = ContainerConfig.load("#{key}_PERFORM_DELIVERIES", default: ::Rails.env.production?, type: :boolean)
  mail_config[:perform_caching] = ContainerConfig.load("#{key}_PERFORM_CACHING", default: false, type: :boolean)
  mail_config[:raise_delivery_errors] = ContainerConfig.load("#{key}_RAISE_DELIVERY_ERRORS", default: false, type: :boolean)
  mail_config[:delivery_method] = ContainerConfig.load("#{key}_DELIVERY_METHOD", default: :sendmail, type: :symbol, enum: %i[smtp sendmail])
  mail_config[:sendmail_settings] = mailer_sendmail_settings(key, **options)
  mail_config[:smtp_settings] = mailer_smtp_settings(key, **options)

  mail_config.compact
end