Sha256: 28fa56934ba6a41207f5d80f41cc02ced23b64e1135735ab8a5d9da6e669cc26

Contents?: true

Size: 983 Bytes

Versions: 13

Compression:

Stored size: 983 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 }.compact_blank!
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
decidim-core-0.28.1 app/mailers/decidim/application_mailer.rb
decidim-core-0.27.6 app/mailers/decidim/application_mailer.rb
decidim-core-0.28.0 app/mailers/decidim/application_mailer.rb
decidim-core-0.27.5 app/mailers/decidim/application_mailer.rb
decidim-core-0.28.0.rc5 app/mailers/decidim/application_mailer.rb
decidim-core-0.28.0.rc4 app/mailers/decidim/application_mailer.rb
decidim-core-0.27.4 app/mailers/decidim/application_mailer.rb
decidim-core-0.27.3 app/mailers/decidim/application_mailer.rb
decidim-core-0.27.2 app/mailers/decidim/application_mailer.rb
decidim-core-0.27.1 app/mailers/decidim/application_mailer.rb
decidim-core-0.27.0 app/mailers/decidim/application_mailer.rb
decidim-core-0.27.0.rc2 app/mailers/decidim/application_mailer.rb
decidim-core-0.27.0.rc1 app/mailers/decidim/application_mailer.rb