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
  self.new.override! if override?
end

.override?Boolean


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

def self.override?
  Config.override_actionmailer_config
end

Instance Method Details

#override!Object


18
19
20
21
22
23
24
25
26
# File 'lib/spree/core/mail_settings.rb', line 18

def override!
  if Config.enable_mail_delivery
    ActionMailer::Base.default_url_options[:host] ||= Config.site_url
    ActionMailer::Base.smtp_settings = mail_server_settings
    ActionMailer::Base.perform_deliveries = true
  else
    ActionMailer::Base.perform_deliveries = false
  end
end