Class: Spree::Core::MailSettings

Inherits:
Object
  • Object
show all
Defined in:
lib/spree/core/mail_settings.rb

Constant Summary collapse

MAIL_AUTH =
['None', 'plain', 'login', 'cram_md5']
SECURE_CONNECTION_TYPES =
['None','SSL','TLS']

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.initObject

Override the Rails application mail settings based on preferences This makes it possible to configure the mail settings through an admin interface instead of requiring changes to the Rails envrionment file


10
11
12
# File 'lib/spree/core/mail_settings.rb', line 10

def self.init
  override! if override?
end

.override!Object


18
19
20
21
# File 'lib/spree/core/mail_settings.rb', line 18

def self.override!
  ActionMailer::Base.delivery_method = :spree
  ActionMailer::Base.default_url_options[:host] ||= Config.site_url
end

.override?Boolean

Returns:

  • (Boolean)

14
15
16
# File 'lib/spree/core/mail_settings.rb', line 14

def self.override?
  Config.override_actionmailer_config
end

Instance Method Details

#mail_server_settingsObject


23
24
25
26
27
28
29
30
31
# File 'lib/spree/core/mail_settings.rb', line 23

def mail_server_settings
  settings = if need_authentication?
               basic_settings.merge(user_credentials)
             else
               basic_settings
             end

  settings.merge :enable_starttls_auto => secure_connection?
end