Skip to content

Conversation

@pyramation
Copy link
Contributor

@pyramation pyramation commented Jan 18, 2026

Summary

This PR builds on top of PR #577 (feat/cloud-fn-test) and addresses the feedback to move process.env access in smtppostmaster into the centralized environment system (@pgpmjs/env / @pgpmjs/types).

Changes:

  • Added SmtpOptions interface and defaults to @pgpmjs/types
  • Added SMTP_* env var parsing to getEnvVars() in @pgpmjs/env
  • Refactored smtppostmaster to use getEnvOptions() instead of direct process.env access
  • Added optional smtpOverrides parameter to send() for programmatic configuration
  • Added resetTransport() helper for test isolation
  • Updated tests to use the new override pattern
  • Updated README with programmatic override examples

Updates since last revision

  • Fixed snapshot test in pgpm/env/__tests__/__snapshots__/merge.test.ts.snap to include the new smtp defaults

Review & Testing Checklist for Human

  • Verify SmtpOptions interface completeness - Check that pgpm/types/src/pgpm.ts includes all necessary SMTP fields (host, port, secure, user, pass, from, replyTo, TLS options, pool settings, etc.)
  • Check transport caching behavior - The getTransport() function in packages/smtppostmaster/src/index.ts creates a new transport when overrides are provided. Verify this doesn't cause issues with connection pooling or resource leaks.
  • Test backward compatibility - The send() function now accepts an optional second parameter. Verify existing callers in functions/send-email-link and functions/simple-email work correctly.
  • Verify env var merging - Test that SMTP_* environment variables are correctly merged with programmatic overrides via getEnvOptions()

Recommended test plan:

  1. Run pnpm --filter @constructive-io/smtppostmaster test to verify unit tests pass
  2. Set SMTP_* env vars and verify they're picked up correctly
  3. Test programmatic overrides by passing config to send() directly
  4. Run the full CI suite to catch any integration issues

Notes

This PR includes all changes from PR #577 plus the env refactor. The original PR changes (jobs consolidation, E2E tests, SMTP switch for cloud functions) should be reviewed as part of PR #577.

Link to Devin run: https://app.devin.ai/sessions/74d34686e5f2432ba8efd913b271b98c
Requested by: Dan Lynch (@pyramation)

Zetazzz and others added 24 commits January 7, 2026 15:00
- Add SmtpOptions interface and defaults to @pgpmjs/types
- Add SMTP_* env var parsing to @pgpmjs/env getEnvVars()
- Refactor smtppostmaster to use getEnvOptions() instead of direct process.env
- Add smtpOverrides parameter to send() for programmatic configuration
- Add resetTransport() helper for test isolation
- Update tests to use smtpOverrides instead of env manipulation
- Update README with new programmatic override examples

Addresses PR #577 feedback to move process.env access into the
centralized environment system.
@devin-ai-integration
Copy link
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@pyramation pyramation merged commit ada5524 into main Jan 18, 2026
37 checks passed
@pyramation pyramation deleted the devin/1768714819-smtp-env-refactor branch January 18, 2026 06:10
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.

3 participants