diff --git a/Gemfile b/Gemfile index 8106763..b361b3e 100644 --- a/Gemfile +++ b/Gemfile @@ -61,4 +61,5 @@ gem 'devise-i18n' group :production do gem 'lograge' + gem 'exception_notification' end diff --git a/Gemfile.lock b/Gemfile.lock index 95a2cc9..52b5974 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -98,6 +98,9 @@ GEM devise (>= 4.8.0) errbase (0.2.1) erubi (1.10.0) + exception_notification (4.5.0) + actionmailer (>= 5.2, < 8) + activesupport (>= 5.2, < 8) ffi (1.15.4-x86_64-linux-musl) globalid (1.0.0) activesupport (>= 5.0) @@ -264,6 +267,7 @@ DEPENDENCIES capybara (>= 3.26) devise devise-i18n + exception_notification jbuilder (~> 2.7) listen (~> 3.3) lograge diff --git a/config/environments/production.rb b/config/environments/production.rb index 8f9f202..bae7a6d 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -92,6 +92,34 @@ Rails.application.configure do # Do not dump schema after migrations. config.active_record.dump_schema_after_migration = false + mailer_default_from = ENV.fetch('DEFAULT_FROM', 'noreply@sutty.nl') + + config.action_mailer.perform_deliveries = true + config.action_mailer.raise_delivery_errors = true + config.action_mailer.delivery_method = :smtp + + config.action_mailer.default_url_options = { + host: ENV.fetch('PUBLIC_HOSTNAME', 'ectomobile.sutty.nl'), + protocol: 'https' + } + + config.action_mailer.smtp_settings = { + address: ENV.fetch('MAIL_SERVER', 'localhost'), + domain: mailer_default_from.split('@', 2).last.gsub(/[^a-z0-9\.]/, ''), + enable_starttls_auto: false + } + + config.action_mailer.default_options = { + from: mailer_default_from + } + + config.middleware.use ExceptionNotification::Rack, + email: { + email_prefix: '[Ectomobile] ', + sender_address: mailer_default_from, + exception_recipients: ENV.fetch('EXCEPTIONS_RECIPIENTS', 'excepciones@sutty.nl').split(',') + } + # Inserts middleware to perform automatic connection switching. # The `database_selector` hash is used to pass options to the DatabaseSelector # middleware. The `delay` is used to determine how long to wait after a write