Skip to content

fix: disable email delivery when SMTP is not configured#831

Open
rewritten wants to merge 2 commits intocoopdevs:developfrom
rewritten:fix/822-827-disable-email-without-smtp
Open

fix: disable email delivery when SMTP is not configured#831
rewritten wants to merge 2 commits intocoopdevs:developfrom
rewritten:fix/822-827-disable-email-without-smtp

Conversation

@rewritten
Copy link
Contributor

Summary

  • When no SMTP_* environment variables are set, fall back to :test delivery method instead of attempting SMTP (which would crash with a 500 error)
  • Print a startup warning: [TimeOverflow] No SMTP configuration found (SMTP_* env vars). Email delivery is disabled.
  • When SMTP vars are present, behaviour is unchanged

Fixes #822, refs #827.

Test plan

  • Boot the app without any SMTP_* env vars — confirm no email-related errors and the warning appears in logs
  • Boot the app with SMTP_* env vars set — confirm emails are delivered normally via SMTP

🤖 Generated with Claude Code

…vs#822, refs coopdevs#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 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 26, 2026 12:41
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adjusts production environment mailer configuration so the app can boot and operate without SMTP settings, aligning with #822 by preventing SMTP-related failures when SMTP_* env vars are absent.

Changes:

  • Builds smtp_env from SMTP_* environment variables using ENV.filter(...).to_h(...).
  • Sets Action Mailer delivery method to :smtp only when SMTP settings are present.
  • Falls back to a non-SMTP delivery method and emits a startup warning when SMTP is not configured.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +90 to +91
smtp_env = ENV.filter { |k, _| k.start_with?("SMTP_") }
.to_h { |k, v| [k.delete_prefix("SMTP_").downcase.to_sym, YAML.load(v)] }
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

YAML.load(v) will deserialize arbitrary YAML from environment variables, which can instantiate unexpected Ruby objects and is generally unsafe. Prefer YAML.safe_load (permitting only basic scalar types you expect) or explicit casting (e.g., int/bool parsing) for SMTP settings values.

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Functional development setup without SMTP?

2 participants