Sha256: 042282a07175d6bddca1170d4e839fd2116f5fcb5aef642baa8338a27061c8ba

Contents?: true

Size: 997 Bytes

Versions: 19

Compression:

Stored size: 997 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
    include MultitenantAssetHost
    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.reply_to = mail.reply_to || Decidim.config.mailer_reply
      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

19 entries across 19 versions & 1 rubygems

Version Path
decidim-core-0.26.10 app/mailers/decidim/application_mailer.rb
decidim-core-0.26.9 app/mailers/decidim/application_mailer.rb
decidim-core-0.26.8 app/mailers/decidim/application_mailer.rb
decidim-core-0.26.7 app/mailers/decidim/application_mailer.rb
decidim-core-0.26.5 app/mailers/decidim/application_mailer.rb
decidim-core-0.26.4 app/mailers/decidim/application_mailer.rb
decidim-core-0.26.3 app/mailers/decidim/application_mailer.rb
decidim-core-0.26.2 app/mailers/decidim/application_mailer.rb
decidim-core-0.26.1 app/mailers/decidim/application_mailer.rb
decidim-core-0.26.0 app/mailers/decidim/application_mailer.rb
decidim-core-0.26.0.rc2 app/mailers/decidim/application_mailer.rb
decidim-core-0.26.0.rc1 app/mailers/decidim/application_mailer.rb
decidim-core-0.25.2 app/mailers/decidim/application_mailer.rb
decidim-core-0.25.1 app/mailers/decidim/application_mailer.rb
decidim-core-0.25.0 app/mailers/decidim/application_mailer.rb
decidim-core-0.25.0.rc4 app/mailers/decidim/application_mailer.rb
decidim-core-0.25.0.rc3 app/mailers/decidim/application_mailer.rb
decidim-core-0.25.0.rc2 app/mailers/decidim/application_mailer.rb
decidim-core-0.25.0.rc1 app/mailers/decidim/application_mailer.rb