Repository navigation
feat(email): send preview mail over Mailpit's HTTP API, so a routine can post links - #854
Merged
Merged
Conversation
…can post links A Claude routine reaches the network only through an HTTPS proxy, so the preview scripts' SMTP send to Mailpit's TCP proxy timed out there (#807) and no loop PR could carry an email preview link (#847, #853). The capture transport now posts to Mailpit's `POST /api/v1/send` instead, authenticated with a send-only `MAILPIT_SEND_AUTH` (Mailpit's `MP_SEND_API_AUTH`), falling back to `MAILPIT_UI_AUTH` while no send credential is configured. The scripts no longer read `SMTP_URL`; the app still sends through it. Also records where previews get `SMTP_URL` from: production's service, where it is inert, since Railway copies production's variables into every PR environment. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
🚅 Deployed to the SahajCloud-pr-854 environment in sahajcloud
1 service not affected by this PR
|
railway-app
Bot
temporarily deployed
to
sahajcloud / SahajCloud-pr-854
September 25, 2026 23:03
Destroyed
…-only one Mailpit holds nothing a read login could leak: a preview's database has no production rows, and production mail goes to Resend. So one credential, MAILPIT_UI_AUTH, serves the scripts, the reviewer and the routine, which can now open its own previews too. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
railway-app
Bot
temporarily deployed
to
sahajcloud / SahajCloud-pr-854
September 25, 2026 23:12
Destroyed
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
preview-*-emailsscripts now post to Mailpit over HTTPS, so a Claude routine can finally run them.MAILPIT_UI_AUTH, which the routine can also read with.SMTP_URLis now set on production's service, so every new Railway preview captures its mail.Changes
scripts/mailpit-transport.ts— a nodemailer custom transport overPOST /api/v1/send, replacing SMTP.createCaptureTransport()keeps its shape, so the four scripts are untouched.tests/unit/mailpit-transport.spec.ts— the message mapping, the auth header, and a refused send.docs/rules/email.md,docs/environment.md,scripts/AGENTS.md— the variables, and why SMTP cannot be the path.Preview
No route changes; the deploy serves nothing this PR touches.
Email previews
Sent through the new transport with
SMTP_URLunset:.icsattachment survive the mappingTest results
.claude/skills/pr-prep/check.sh— lint, typecheck (src), typecheck (tests), 2197 unit testsmailpit-transport.spec.ts, 7 passedpreview-*-emailsscripts ran over HTTPS withSMTP_URLunset — 26 links, 0 errorspnpm typecheckpasses with itspreview-manager-emails.tsNotes for reviewer
SMTP_URLon production's SahajCloud service, set with--skip-deploys, so production did not redeploy. It has no effect there, because the Resend branch is taken first. It is also set by hand onSahajCloud-pr-853, which was created before it existed.MAILPIT_URLandMAILPIT_UI_AUTHin the Claude cloud environment. Until then, a routine has no credential.previewIsolation.ts), and production mail goes to Resend. A send-only credential (MP_SEND_API_AUTH) would protect nothing and would stop the routine opening its own previews.Detail
Why HTTP rather than fixing SMTP. A routine's egress is an HTTPS proxy. There is no configuration of the cloud environment that lets raw SMTP through, and #807 already recorded the timeout. The one thing both a routine and a laptop can reach is HTTPS.
Fidelity. The scripts still drive the real senders. Only the last hop changed: nodemailer normalizes the message, and the transport maps it onto Mailpit's JSON body. That is also the shape production uses, since Resend takes JSON rather than MIME. No sender sets custom headers today.
Headersis mapped anyway and asserted in the spec.The base64 branch.
normalize()base64-encodes Buffer content but leaves string content in its own encoding.Buffer.from(content, encoding)re-encodes both correctly, so there is a single path.🤖 Generated with Claude Code