Skip to content

Make email sender/reply-to env-configurable for SCCN - #345

Merged
neuromechanist merged 4 commits into
devfrom
feature/issue-328-email-env-config
Apr 18, 2026
Merged

neuromechanist merged 4 commits into
devfrom
feature/issue-328-email-env-config

Conversation

@neuromechanist

Copy link
Copy Markdown
Contributor

Summary

Phase 7 of SCCN Cloudflare migration (#328 / Epic #314): decouple the Resend sender address from the personal osc.earth domain so the SCCN worker can send from [email protected] without forking the email service.

  • Thread fromEmail + optional replyTo through sendEmail, all 8 exported email wrappers in backend/src/services/email.ts, and sendBroadcast in backend/src/services/broadcast.ts
  • Add resolveEmailConfig(env) helper so route handlers pull sender/reply-to from c.env without repeating the fallback
  • Add FROM_EMAIL? and REPLY_TO? to Bindings
  • Wire FROM_EMAIL = "NEMAR <[email protected]>" in backend/wrangler.toml (prod + dev) — personal behavior unchanged
  • Wire FROM_EMAIL = "NEMAR Archive <[email protected]>" + REPLY_TO = "[email protected]" in backend/wrangler-sccn.toml (prod + dev)
  • 11 callsites across routes/{auth,admin,datasets}.ts updated

DEFAULT_FROM_EMAIL remains exported as a safety fallback if the env var is ever unset.

Test plan

  • bun run typecheck clean
  • bun test — 26/26 pass
  • biome check clean on modified files
  • wrangler deploy --dry-run on both configs shows correct bindings
  • Resend domain nemar.org verified (DKIM + SPF + bounce MX present)
  • Direct Resend API smoke test: email delivered with From: NEMAR Archive <[email protected]> and Reply-To: [email protected]
  • Deployed to both SCCN dev (nemar-api-dev.sccn-org.workers.dev) and SCCN prod (nemar-api.sccn-org.workers.dev); /health returns 200
  • End-to-end signup flow against SCCN dev (optional; direct Resend test already proves the send path)

Related

@github-actions

github-actions Bot commented Apr 18, 2026 •

Copy link
Copy Markdown

📦 Package Preview

Your package is ready to test!

bun install -g nemar-cli@PR345

Version: 0.7.26-PR345.05d13ed
Commit: 05d13ed


🤖 Updated on each push.

@neuromechanist

Copy link
Copy Markdown
Contributor Author

PR Review Summary (4 agents)

code-reviewer

No high-confidence issues. Refactor complete and consistent; all 11 callsites threaded correctly; reply_to snake_case matches Resend schema.

silent-failure-hunter

  • HIGH: resolveEmailConfig only fell back on null/undefined; empty/whitespace FROM_EMAIL would pass through and Resend would reject silently. → Fixed in fbc7684: trim + falsy fallback; empty/whitespace REPLY_TO now dropped.
  • MEDIUM: No runtime guard against deploying before domain verification. → Skipped as scope creep; the TOML comment and deploy checklist already flag it.
  • LOW: Thrown error didn't include fromEmail context. → Fixed in fbc7684: error message now includes sender + recipient.

comment-analyzer

  • JSDoc "sensible defaults" (plural) was misleading. → Fixed: rewritten to clarify fromEmail/replyTo semantics separately.
  • Personal wrangler.toml didn't explain why REPLY_TO is omitted. → Fixed: added "[email protected] is monitored" note.
  • Bindings JSDoc didn't mention domain-verification caveat. → Fixed.
  • SCCN wrangler-sccn.toml comment could mention the silent-failure consequence. → Fixed.

pr-test-analyzer

Recommended a unit test for resolveEmailConfig (pure function, textbook unit-test candidate). → Added backend/test/email-config.test.ts with 6 tests covering all branches + whitespace handling. 32/32 total tests pass (was 26, +6).

Final state

  • Typecheck clean
  • 32/32 tests pass
  • Biome clean on modified files
  • Both commits on branch: c49a8d7 (initial refactor), fbc7684 (review fixes)

@neuromechanist
neuromechanist merged commit 212da84 into dev Apr 18, 2026
8 checks passed
@neuromechanist
neuromechanist deleted the feature/issue-328-email-env-config branch April 18, 2026 07:56

This branch was previously deployed

1 inactive deployment
npm — 05d13eda Deployed Apr 18, 2026 by neuromechanist via publish #606
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