Skip to content

A platform for community discussion. Free, open, simple.

DEV: add DISCOURSE_USE_SMTP_ENVIRONMENT_IN_DEVELOPMENT for overriding safety checks

Michael Brown3a5c12f73846
diff --git a/config/environment.rb b/config/environment.rb
index 90ea3b4fa98..85f4894fa80 100644
--- a/config/environment.rb
+++ b/config/environment.rb
@@ -7,7 +7,7 @@ require_relative "application"
Rails.application.initialize!
# When in "dev" mode, ensure we won't be sending any emails
-if Rails.env.development? &&
+if Rails.env.development? && !GlobalSetting.try(:use_smtp_environment_in_development) &&
ActionMailer::Base.smtp_settings.slice(:address, :port) != { address: "localhost", port: 1025 }
- fail "In development mode, you should be using mailhog otherwise you might end up sending thousands of digest emails"
+ fail "In development mode, you should be using a local development mail server to avoid unintentionally sending real mail"
end
diff --git a/config/environments/development.rb b/config/environments/development.rb
index 6632976910d..d7b318f67db 100644
--- a/config/environments/development.rb
+++ b/config/environments/development.rb
@@ -37,8 +37,13 @@ Discourse::Application.configure do
config.active_record.migration_error = :page_load
config.watchable_dirs["lib"] = [:rb]
- # we recommend you use mailhog https://github.com/mailhog/MailHog
- config.action_mailer.smtp_settings = { address: "localhost", port: 1025 }
+ config.action_mailer.smtp_settings =
+ if GlobalSetting.try(:use_smtp_environment_in_development)
+ GlobalSetting.smtp_settings || { address: "localhost", port: 1025 }
+ else
+ # we recommend you use mailpit: https://github.com/axllent/mailpit/
+ { address: "localhost", port: 1025 }
+ end
config.action_mailer.raise_delivery_errors = true