Sha256: 89a7d4e06bb7d44122f235130beacc65f8d34b63f88b2812fb6f8e3629b1e6a3

Contents?: true

Size: 897 Bytes

Versions: 6

Compression:

Stored size: 897 Bytes

Contents

# frozen_string_literal: true

module Decidim
  # Main application mailer configuration. Inherit from this to create new
  # mailers.
  class ApplicationMailer < ActionMailer::Base
    include LocalisedMailer
    after_action :set_smtp

    default from: Decidim.config.mailer_sender
    layout "decidim/mailer"

    private

    def set_smtp
      return if @organization.nil? || @organization.smtp_settings.blank?

      mail.from = @organization.smtp_settings["from"].presence || mail.from
      mail.delivery_method.settings.merge!(
        address: @organization.smtp_settings["address"],
        port: @organization.smtp_settings["port"],
        user_name: @organization.smtp_settings["user_name"],
        password: Decidim::AttributeEncryptor.decrypt(@organization.smtp_settings["encrypted_password"])
      ) { |_k, o, v| v.presence || o }.reject! { |_k, v| v.blank? }
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
decidim-core-0.21.0 app/mailers/decidim/application_mailer.rb
decidim-core-0.20.1 app/mailers/decidim/application_mailer.rb
decidim-core-0.20.0 app/mailers/decidim/application_mailer.rb
decidim-core-0.19.1 app/mailers/decidim/application_mailer.rb
decidim-core-0.18.1 app/mailers/decidim/application_mailer.rb
decidim-core-0.19.0 app/mailers/decidim/application_mailer.rb