Skip to content

feat(email): send preview mail over Mailpit's HTTP API, so a routine can post links - #854

Merged
Ardnived merged 2 commits into
mainfrom
claude/feat-mailpit-http-send
Sep 25, 2026
Merged

Ardnived merged 2 commits into
mainfrom
claude/feat-mailpit-http-send

Conversation

@Ardnived

@Ardnived Ardnived commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • The preview-*-emails scripts now post to Mailpit over HTTPS, so a Claude routine can finally run them.
  • They authenticate with the existing Mailpit login, MAILPIT_UI_AUTH, which the routine can also read with.
  • SMTP_URL is now set on production's service, so every new Railway preview captures its mail.

Changes

  • scripts/mailpit-transport.ts — a nodemailer custom transport over POST /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_URL unset:

Test results

  • Lean gate: ✓ .claude/skills/pr-prep/check.sh — lint, typecheck (src), typecheck (tests), 2197 unit tests
  • Targeted specs: ✓ mailpit-transport.spec.ts, 7 passed
  • End to end: ✓ all four preview-*-emails scripts ran over HTTPS with SMTP_URL unset — 26 links, 0 errors
  • Merged onto feat(email)!: invite a manager to what they are assigned, and let a reminder sign them in #853's head: merges cleanly, and pnpm typecheck passes with its preview-manager-emails.ts
  • Build: N/A — Railway builds it for the preview

Notes for reviewer

  • Already done on Railway: SMTP_URL on 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 on SahajCloud-pr-853, which was created before it existed.
  • Still owed, in the claude.ai UI: MAILPIT_URL and MAILPIT_UI_AUTH in the Claude cloud environment. Until then, a routine has no credential.
  • A read login is deliberate. Mailpit holds only fixtures and preview traffic: a preview's database has no production rows (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. Headers is 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

…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]>
@railway-app

railway-app Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

🚅 Deployed to the SahajCloud-pr-854 environment in sahajcloud

Service Status Web Updated
SahajCloud ✅ Success (View Logs) Web Sep 25, 2026 at 11:14 pm UTC
1 service not affected by this PR
  • mailpit

…-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
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-854 September 25, 2026 23:12 Destroyed
@Ardnived
Ardnived merged commit 0187836 into main Sep 25, 2026
5 checks passed
@Ardnived
Ardnived deleted the claude/feat-mailpit-http-send branch September 25, 2026 23:26

This branch was successfully deployed

No deployments
sahajcloud / SahajCloud-pr-854 — 973236ac Deployed Sep 25, 2026 by railway-app[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

1 participant