fix: preserve safe headers through SMTP proxy - #432
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (6)
WalkthroughThe SMTP server now extracts eligible forwarded headers, unfolds and validates their values, and includes them with CC and BCC fields in outbound email payloads. Vitest is configured for SMTP tests. Web header sanitization now rejects a broader set of reserved names and prefixes, with additional test coverage for content, DKIM, ARC, and SES-related headers. Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install timed out. The project may have too many dependencies for the sandbox. 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. Comment |
Deploying usesend with
|
| Latest commit: |
fc1784c
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://c6878728.usesend.pages.dev |
| Branch Preview URL: | https://codex-smtp-header-forwarding.usesend.pages.dev |
Summary
Why
The SMTP proxy currently reconstructs an API payload from a small subset of Mailparser fields. That silently drops unsubscribe, threading, automation, feedback, and application-specific headers.
Forwarding every raw header without a policy is unsafe because content/transport headers are rebuilt downstream, authentication signatures become stale, and provider control headers must not be client-controlled. This keeps useful end-to-end headers by default while excluding the categories that useSend, Nodemailer, or SES owns.
This includes @mattstein's original commit from #428 with its original authorship, then builds the general fix on top.
Verification
pnpm --filter smtp-server testpnpm --filter smtp-server exec tsc --noEmitpnpm --filter web exec vitest run -c vitest.unit.config.ts src/server/utils/email-headers.unit.test.tsgit diff --checkNo migrations or build commands were run.
Summary by cubic
Preserves safe end-to-end headers through the SMTP proxy and blocks unsafe ones, so unsubscribe, threading, automation, and custom headers make it to the API. Also maps Cc/Bcc correctly and unfolds folded header values.
Bug Fixes
headersfield and unfold folded values.x-usesend*headers at SMTP and API boundaries.Dependencies
vitestand enableapps/smtp-servertests.Written for commit fc1784c. Summary will update on new commits.
Summary by CodeRabbit
New Features
Bug Fixes
Tests