From 2fe1732a57427b69bd14628b0d8bbdc30350e463 Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Sat, 27 Aug 2011 11:42:49 +0800 Subject: [PATCH] Allow optional configuration of SMTP settings in config.yml --- config/config.example.yml | 28 +++++++++++++++++++++------- config/initializers/_load_config.rb | 7 ++++++- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/config/config.example.yml b/config/config.example.yml index d1fa754..a507d9f 100644 --- a/config/config.example.yml +++ b/config/config.example.yml @@ -28,16 +28,30 @@ email_at_notices: [1, 10, 100] confirm_resolve_err: true # Add an optional 'username' field to Users. -# Helpful if you want to plug in your own authentication strategy. +# Helpful when you need to plug in a custom authentication strategy, such as LDAP. user_has_username: false + +# Configure SMTP settings. If you are running Errbit on Heroku, +# sendgrid will be configured by default. +# ------------------------------------------------------------------------ +#smtp_settings: +# :address: ADDRESS +# :domain: DOMAIN +# :port: "25" +# :authentication: :plain, :login, :cram_md5 +# :enable_starttls_auto: true +# :user_name: USERNAME +# :password: PASSWORD + + # Configure tracking for Errbit's own internal errors. # There is a central Errbit instance running on heroku, # and other Errbit instances will send their errors there by default. -# Please leave this section commented unless you really need to change it. -# ------------------------------------------------------------------------ -# report_self_errors: true -# self_errors_host: errbit-central.heroku.com -# self_errors_port: 80 -# self_errors_api_key: 11e5ce322856e540481e6a0789893179 +# Please leave this section commented if you don't need to override the defaults. +# ------------------------------------------------------------------------------- +#report_self_errors: true +#self_errors_host: errbit-central.heroku.com +#self_errors_port: 80 +#self_errors_api_key: 11e5ce322856e540481e6a0789893179 diff --git a/config/initializers/_load_config.rb b/config/initializers/_load_config.rb index bf0ff13..e9eeb2c 100644 --- a/config/initializers/_load_config.rb +++ b/config/initializers/_load_config.rb @@ -12,7 +12,7 @@ if ENV['HEROKU'] Errbit::Config.self_errors_port = ENV['ERRBIT_SELF_ERRORS_PORT'] Errbit::Config.self_errors_api_key = ENV['ERRBIT_SELF_ERRORS_API_KEY'] - Errbit::Application.config.action_mailer.smtp_settings = { + Errbit::Config.smtp_settings = { :address => "smtp.sendgrid.net", :port => "25", :authentication => :plain, @@ -33,6 +33,11 @@ if File.exists?(config_file) end end +# Set SMTP settings if given, but retain defaults if not. +if smtp = Errbit::Config.smtp_settings + Errbit::Application.config.action_mailer.smtp_settings = smtp +end + # Set config specific values (Errbit::Application.config.action_mailer.default_url_options ||= {}).tap do |default| default.merge! :host => Errbit::Config.host if default[:host].blank? -- libgit2 0.21.2