Sha256: 098b1ddbd2e1a6e0415f4e1b88446a921b14d8462d6671736904dbef75c620b6

Contents?: true

Size: 1.25 KB

Versions: 3

Compression:

Stored size: 1.25 KB

Contents

module Spree
  module MailSettings

    # Override the Rails application mail settings based on preference.  This makes it possible to configure the mail settings
    # through an admin interface instead of requiring changes to the Rails envrionment file.
    def self.init
      return unless mail_method = MailMethod.current
      if mail_method.prefers_enable_mail_delivery?
        mail_server_settings = {
          :address => mail_method.preferred_mail_host,
          :domain => mail_method.preferred_mail_domain,
          :port => mail_method.preferred_mail_port,
          :authentication => mail_method.preferred_mail_auth_type
        }

        if mail_method.preferred_mail_auth_type != 'none'
          mail_server_settings[:user_name] = mail_method.preferred_smtp_username
          mail_server_settings[:password] = mail_method.preferred_smtp_password
        end

        ActionMailer::Base.smtp_settings = mail_server_settings
        ActionMailer::Base.perform_deliveries = true

        if mail_method.preferred_secure_connection_type == 'TLS'
          mail_server_settings[:enable_starttls_auto] = true
        end
      else
        #logger.warn "NOTICE: Mail not enabled"
        ActionMailer::Base.perform_deliveries = false
      end
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
spree_core-0.30.2 lib/spree/mail_settings.rb
spree_core-0.30.1 lib/spree/mail_settings.rb
spree_core-0.30.0 lib/spree/mail_settings.rb