Skip to content

Commit

Permalink
moved smtp config to separate .yml file
Browse files Browse the repository at this point in the history
  • Loading branch information
nbartlomiej committed Apr 5, 2011
1 parent 74c4b63 commit 1218d80
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Expand Up @@ -34,8 +34,8 @@ GEM
capistrano (2.5.20)
highline
highline
net-scp
net-scp (>= 1.0.0)
net-scp
net-sftp
net-sftp (>= 2.0.0)
net-ssh (>= 2.0.14)
Expand Down
11 changes: 0 additions & 11 deletions config/environments/development.rb
Expand Up @@ -26,17 +26,6 @@
# path to ImageMagick, for paperclip
Paperclip.options[:command_path] = '/usr/local/bin/'

# gmail account data, for sending mails
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "applicake.com",
:user_name => "companyhandbook@applicake.com",
:password => "INSERT_PASSWORD_HERE",
:authentication => "plain",
:enable_starttls_auto => true
}

config.action_mailer.default_url_options = { :host => 'localhost:3000' }

end
Expand Down
11 changes: 0 additions & 11 deletions config/environments/production.rb
Expand Up @@ -50,17 +50,6 @@
# path to ImageMagick, for paperclip
Paperclip.options[:command_path] = '/usr/bin/'

# gmail account data, for sending mails
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "applicake.com",
:user_name => "companyhandbook@applicake.com",
:password => "INSERT_PASSWORD_HERE",
:authentication => "plain",
:enable_starttls_auto => true
}

# required by devise
config.action_mailer.default_url_options = { :host => 'applicake.com' }

Expand Down
34 changes: 34 additions & 0 deletions config/initializers/setup_mail.rb
@@ -0,0 +1,34 @@
# Loading email config from #{Rails.root}/config/smtp.yml file, for
# a given rails environment.
#
# Note that by default yaml hash keys are strings and
# ActionMailer::Base.smtp_settings requires symbols; we're using
# the symbolize_keys (a.k.a. to_options) method from core rails
# extensions
#
#
# Sample file for a Gmail smtp with custom domain (custom-domain.com)
#
# development:
# address: smtp.gmail.com
# port: 587
# domain: custom-domain.com
# user_name: companyhandbook@custom-domain.com
# password: INSERT_PASSWORD_HERE
# authentication: plain
# enable_starttls_auto: true
#
# production:
# address: smtp.gmail.com
# port: 587
# domain: custom-domain.com
# user_name: companyhandbook@custom-domain.com
# password: INSERT_PASSWORD_HERE
# authentication: plain
# enable_starttls_auto: true

# ActionMailer::Base.smtp_settings = YAML.load_file("#{Rails.root}/config/smtp.yml")[Rails.env]

CorporateHandbook::Application.configure do
config.action_mailer.smtp_settings = YAML.load_file("#{Rails.root}/config/smtp.yml")[Rails.env].symbolize_keys
end

0 comments on commit 1218d80

Please sign in to comment.