From 5036b968b536ca3b4b3786e4fe606868bf4b1f29 Mon Sep 17 00:00:00 2001 From: Saverio Trioni <476895+rewritten@users.noreply.github.com> Date: Thu, 26 Mar 2026 13:40:12 +0100 Subject: [PATCH 1/2] fix: disable email delivery when SMTP is not configured (fixes #822, refs #827) When no SMTP_* environment variables are set, fall back to :test delivery method instead of attempting SMTP, and print a warning at startup. Co-Authored-By: Claude Sonnet 4.6 --- config/environments/production.rb | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/config/environments/production.rb b/config/environments/production.rb index 6bca2198..7b55666e 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -82,20 +82,21 @@ # Set this to true and configure the email server for immediate delivery to raise delivery errors. # config.action_mailer.raise_delivery_errors = false - config.action_mailer.delivery_method = :smtp config.action_mailer.default_url_options = { host: ENV["MAIL_LINK_HOST"], protocol: ENV["MAIL_LINK_PROTO"] || "https" } - smtp_env = Hash[ENV.map do |k, v| - if /^SMTP_(.*)$/ === k - [$1.downcase.to_sym, YAML.load(v)] - end - end.compact] + smtp_env = ENV.filter { |k, _| k.start_with?("SMTP_") } + .to_h { |k, v| [k.delete_prefix("SMTP_").downcase.to_sym, YAML.load(v)] } + if smtp_env.present? + config.action_mailer.delivery_method = :smtp config.action_mailer.smtp_settings = smtp_env + else + config.action_mailer.delivery_method = :test + warn "[TimeOverflow] No SMTP configuration found (SMTP_* env vars). Email delivery is disabled." end # Enable locale fallbacks for I18n (makes lookups for any locale fall back to From 1fbc83947a379ba70fff0a6c1c5ed9aae474629d Mon Sep 17 00:00:00 2001 From: Saverio Trioni <476895+rewritten@users.noreply.github.com> Date: Thu, 26 Mar 2026 14:05:20 +0100 Subject: [PATCH 2/2] Update config/environments/production.rb Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- config/environments/production.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/config/environments/production.rb b/config/environments/production.rb index 7b55666e..11b5fffd 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -96,6 +96,7 @@ config.action_mailer.smtp_settings = smtp_env else config.action_mailer.delivery_method = :test + config.action_mailer.perform_deliveries = false warn "[TimeOverflow] No SMTP configuration found (SMTP_* env vars). Email delivery is disabled." end