mirror of
https://github.com/discourse/discourse.git
synced 2026-09-05 04:40:41 -05:00
DEV: Add env var for local email port (#36900)
This commit adds DISCOURSE_LOCAL_EMAIL_PORT environment variable to allow setting a port other than 1025 for local mail. This is added because now macOS has a system service using port 1025, causing conflicts when running a local mail server for Discourse development.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user