Skip to content

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

DEV: Add env var for local email port (#36900)

Martin Brennan867c2f00964d
diff --git a/config/environment.rb b/config/environment.rb
index 85f4894fa80..4fa3f8deafc 100644
--- a/config/environment.rb
+++ b/config/environment.rb
@@ -8,6 +8,7 @@ Rails.application.initialize!
# When in "dev" mode, ensure we won't be sending any emails
if Rails.env.development? && !GlobalSetting.try(:use_smtp_environment_in_development) &&
- ActionMailer::Base.smtp_settings.slice(:address, :port) != { address: "localhost", port: 1025 }
+ ActionMailer::Base.smtp_settings.slice(:address, :port) !=
+ { address: "localhost", port: ENV["DISCOURSE_LOCAL_EMAIL_PORT"] || 1025 }
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 0d6774899ed..e60babb8c27 100644
--- a/config/environments/development.rb
+++ b/config/environments/development.rb
@@ -39,10 +39,11 @@ Discourse::Application.configure do
config.action_mailer.smtp_settings =
if GlobalSetting.try(:use_smtp_environment_in_development)
- GlobalSetting.smtp_settings || { address: "localhost", port: 1025 }
+ GlobalSetting.smtp_settings ||
+ { address: "localhost", port: ENV["DISCOURSE_LOCAL_EMAIL_PORT"] || 1025 }
else
# we recommend you use mailpit: https://github.com/axllent/mailpit/
- { address: "localhost", port: 1025 }
+ { address: "localhost", port: ENV["DISCOURSE_LOCAL_EMAIL_PORT"] || 1025 }
end
config.action_mailer.raise_delivery_errors = true
diff --git a/config/environments/profile.rb b/config/environments/profile.rb
index 6bae875bec6..1f9a1f02554 100644
--- a/config/environments/profile.rb
+++ b/config/environments/profile.rb
@@ -30,7 +30,10 @@ Discourse::Application.configure do
config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for nginx
# we recommend you use mailhog https://github.com/mailhog/MailHog
- config.action_mailer.smtp_settings = { address: "localhost", port: 1025 }
+ config.action_mailer.smtp_settings = {
+ address: "localhost",
+ port: ENV["DISCOURSE_LOCAL_EMAIL_PORT"] || 1025,
+ }
# Send deprecation notices to registered listeners
config.active_support.deprecation = :notify