Skip to content

feat(shared): decompose SMTP_CONNECTION_URL into individual env vars#1002

Merged
msukkari merged 3 commits intomainfrom
msukkari/smtp-env-vars-SOU-637
Mar 13, 2026
Merged

feat(shared): decompose SMTP_CONNECTION_URL into individual env vars#1002
msukkari merged 3 commits intomainfrom
msukkari/smtp-env-vars-SOU-637

Conversation

@msukkari
Copy link
Contributor

@msukkari msukkari commented Mar 13, 2026

Summary

Add support for configuring SMTP via individual environment variables (SMTP_HOST, SMTP_PORT, SMTP_USERNAME, SMTP_PASSWORD) as an alternative to providing the full SMTP_CONNECTION_URL. This mirrors how DATABASE_URL can be decomposed into separate components.

Changes

  • Created packages/shared/src/smtp.ts with getSMTPConnectionURL() helper that constructs the connection URL, maintaining backward compatibility
  • Updated packages/shared/src/env.server.ts to define the new SMTP environment variables
  • Updated entrypoint.sh to support SMTP URL construction at the shell level
  • Modified packages/web/src/auth.ts and packages/web/src/actions.ts to use the new helper function
  • Updated documentation to show both configuration methods with precedence rules

Fixes SOU-637

Summary by CodeRabbit

  • New Features

    • SMTP can now be configured using individual environment variables (SMTP_HOST, SMTP_PORT, SMTP_USERNAME, SMTP_PASSWORD) as an alternative to SMTP_CONNECTION_URL.
  • Documentation

    • Updated configuration documentation to include the new SMTP environment variable options and their usage.

@github-actions

This comment has been minimized.

msukkari added a commit that referenced this pull request Mar 13, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 13, 2026

Caution

Review failed

Pull request was closed or merged during review

Walkthrough

This PR introduces support for configuring SMTP via individual environment variables (SMTP_HOST, SMTP_PORT, SMTP_USERNAME, SMTP_PASSWORD) as an alternative to SMTP_CONNECTION_URL. A new utility function constructs SMTP connection URLs from individual variables when the monolithic connection string is unavailable. Documentation and email-sending code paths are updated accordingly.

Changes

Cohort / File(s) Summary
Documentation
CHANGELOG.md, docs/docs/configuration/environment-variables.mdx, docs/docs/configuration/transactional-emails.mdx
Added documentation for new SMTP environment variables and clarified that individual SMTP settings can be used to construct the connection URL, with SMTP_CONNECTION_URL taking precedence.
Environment Schema
packages/shared/src/env.server.ts
Added four new optional environment variable declarations: SMTP_HOST (string), SMTP_PORT (number), SMTP_USERNAME (string), and SMTP_PASSWORD (string) to the server options schema.
SMTP Utility
packages/shared/src/smtp.ts, packages/shared/src/index.server.ts
Introduced new module with getSMTPConnectionURL() function that returns SMTP_CONNECTION_URL if available, otherwise constructs URL from individual variables, returning undefined if required variables are missing or incompletely configured.
Email Integration
packages/web/src/actions.ts, packages/web/src/auth.ts
Replaced direct env.SMTP_CONNECTION_URL access with getSMTPConnectionURL() utility across multiple email-sending code paths (invites, account requests, join approvals).
Miscellaneous
entrypoint.sh
Corrected comment typo: "Descontruct" → "Construct".

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding support for decomposing SMTP_CONNECTION_URL into individual environment variables (SMTP_HOST, SMTP_PORT, SMTP_USERNAME, SMTP_PASSWORD). It is clear, specific, and concise.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch msukkari/smtp-env-vars-SOU-637
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

msukkari and others added 2 commits March 13, 2026 09:52
Add support for configuring SMTP via individual environment variables (SMTP_HOST, SMTP_PORT, SMTP_USERNAME, SMTP_PASSWORD) similar to how DATABASE_URL can be decomposed. Create getSMTPConnectionURL() helper in new smtp.ts module that constructs the connection URL, maintaining backward compatibility with SMTP_CONNECTION_URL. Update entrypoint.sh, auth.ts, and actions.ts to use the new helper. Decomposition is supported both at the shell level (entrypoint.sh) and TypeScript level (smtp.ts).

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
… decomposed vars

Move SMTP URL construction entirely into getSMTPConnectionURL() in TypeScript.
When using decomposed env vars, all four (SMTP_HOST, SMTP_PORT, SMTP_USERNAME,
SMTP_PASSWORD) are now required. Logs an error listing missing vars if incomplete.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@msukkari msukkari merged commit 3036433 into main Mar 13, 2026
8 checks passed
@msukkari msukkari deleted the msukkari/smtp-env-vars-SOU-637 branch March 13, 2026 17:00
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.

1 participant