Skip to content

Commit

Permalink
mailer SMTP configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
mhanne committed May 7, 2016
1 parent 939fee1 commit 564d940
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 15 deletions.
39 changes: 25 additions & 14 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,25 @@
# Bundler.require(:default, :assets, Rails.env)
end

Bundler.setup

module BlockBrowser
class Application < Rails::Application


begin
::BB_CONFIG = YAML::load_file(File.join(Rails.root, "config/application.yml"))
Bitcoin::network = BB_CONFIG["network"]
backend, db = BB_CONFIG["database"].split("::")
::STORE = Bitcoin::Blockchain.create_store(backend, db: db, index_nhash: true, index_p2sh_type: true)
rescue
p $!
puts "Error loading configuration from config/application.yml; falling back to defaults"
::BB_CONFIG = YAML::load_file(File.join(Rails.root, "config/application.yml.sample"))
end

::WS_CONFIG = BB_CONFIG["websocket"]

# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
Expand Down Expand Up @@ -46,20 +63,14 @@ class Application < Rails::Application

# Version of your assets, change this if you want to expire all your assets
config.assets.version = '1.0'
end
end

require 'bundler'
Bundler.setup
if BB_CONFIG['mailer']
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default_options = { from: BB_CONFIG['mailer']['from'] }
config.action_mailer.smtp_settings = BB_CONFIG['mailer'].symbolize_keys
end

begin
BB_CONFIG = YAML::load_file(File.join(Rails.root, "config/application.yml"))
Bitcoin::network = BB_CONFIG["network"]
backend, config = BB_CONFIG["database"].split("::")
STORE = Bitcoin::Blockchain.create_store(backend, db: config, index_nhash: true, index_p2sh_type: true)
rescue
puts "Error loading configuration from config/application.yml; falling back to defaults"
BB_CONFIG = YAML::load_file(File.join(Rails.root, "config/application.yml.sample"))
end
end

WS_CONFIG = BB_CONFIG["websocket"]
14 changes: 14 additions & 0 deletions config/application.yml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,20 @@ relay_wait_max: 10
# but might become important in relation to the "networks" setting)
domain: "localhost"


# mailer settings
# (set to false to disable mail sending)
mailer:
from: 'system@example.com'
address: 'mail.example.com'
port: 25
domain: 'example.com'
user_name: 'test@example.com'
password: 'password'
authentication: 'plain'
enable_starttls_auto: true


# links to other instances for different networks
networks:
bitcoin: "http://webbtc.com"
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/exception_notification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# Email notifier sends notifications by email.
config.add_notifier :email, {
:email_prefix => "[ERROR] ",
:sender_address => %{"Notifier" <notifier@webbtc.com>},
:sender_address => %{"WebBTC" <system@webbtc.com>},
:exception_recipients => %w{info@webbtc.com}
}

Expand Down

0 comments on commit 564d940

Please sign in to comment.