Skip to content

Deliver company Email transport and migrate mailbox history #5481

Description

@devantler

🤖 Generated by the Agentic Engineer

Summary

Complete company Email transport and move the existing mailbox safely, with ordinary mail-app access and measured delivery.

Motivation

The maintainer selected direct delivery from the company's server and asked for migration from the existing provider. Preparation of the server, administration access and encryption does not establish working inbound mail, outbound delivery or client access. Those outcomes need a distinct delivery slice under #5030.

Proposed Solution

Use the existing declarative platform and DNS owners to publish reviewed mail transport. Establish a stable sending identity, matching reverse DNS, authenticated TLS submission and receiving access before moving domain-wide mail routing. Preserve every existing mailbox and address until continuity and rollback are proved. Exact addresses, infrastructure details, credentials and message history remain in private operator configuration.

Acceptance Criteria

  • Record current transport facts and ownership privately: stable sending address, forward/reverse DNS, provider SMTP permission and an actual server-side outbound SMTP connection. Preserve existing address ownership; any additional recurring cost requires its own authorization.
  • Publish only the intended inbound SMTP, authenticated submission and mailbox-access endpoints through reviewed declarative configuration. Validate certificates, renewal, connectivity and client identity from an independent network.
  • Reject anonymous relay and spoofed authenticated sending identities; preserve the agents' separate maintainer-only recipient restriction. Verify the relevant positive and negative controls against the deployed server.
  • Apply domain routing and SPF, DKIM and DMARC through the reviewed declarative DNS owner, with a tested rollback. Do not move MX before destination delivery, recovery and existing-address inventory are verified.
  • Copy and reconcile existing message history and the complete approved address inventory, proving message counts and representative content privately. Gracefully retire old aliases without deleting shared provider history.
  • Configure the maintainer's normal mail apps and demonstrate authenticated sending, receiving and reading without per-client encryption identities.
  • Observe an authorized external round trip with SPF, DKIM and DMARC passing and inbox placement verified; preserve sanitized evidence and private delivery details.
  • Verify the published configuration after protected merge, complete the documented rollback/recovery exercise and update Company Email infrastructure and service notifications #5030 with the remaining acceptance state.

Dependencies

Part of #5030. Safe activation follows availability recovery (#5412) and the account, encryption and independent-recovery gates (#5387). The business sender (#5400) remains a separate slice and requires this deployed transport for its real delivery proof.

Alternatives Considered

A hosted SMTP relay was considered; the maintainer explicitly selected direct delivery. No relay subscription or new permanent infrastructure is authorized by this issue.

Activity

  1. moved this to 📥 Backlog in 🌊 Project Boardon Oct 28, 2026
  2. coderabbitai commented on Oct 28, 2026

    @coderabbitai
    Contributor
    🔗 Related PRs

    #5388 - feat(email): prepare Email credential custody and recovery [merged]
    #5533 - feat(email): move active credentials and recovery to infrastructure [merged]


    📝 Issue Planner

    Check the box below or use the @coderabbitai plan command to generate an implementation plan and prompts that you can use with your favorite coding assistant.

    • Create Plan

    🧪 Issue enrichment is currently in open beta.

    You can configure auto-planning by selecting labels in the issue_enrichment configuration.

    To disable automatic issue enrichment, add the following to your .coderabbit.yaml:

    issue_enrichment:
      auto_enrich:
        enabled: false

    💬 Have feedback or questions? Drop into our discord!

  3. self-assigned this
    on Nov 1, 2026
  4. added a commit that references this issue on Nov 1, 2026
  5. added 2 commits that reference this issue on Nov 2, 2026
  6. devantler commented on Nov 2, 2026

    @devantler
    ContributorAuthor

    🤖 Generated by the Agentic Engineer

    The repaired connectivity workflow has merged in #5732, and its main validation passed. Confirmed main-only run 41431268753, first attempt at fba2aed2a76c4bf12634b1498861dfdc562a8de1, returned EMAIL_PROVIDER_SMTP=VERIFIED scope=hosting-node-no-message cleanup=verified and EMAIL_PROVIDER_CLEANUP=VERIFIED.

    This proves the reviewed no-message SMTP session and cleanup. It sends no email and does not establish stable sending identity, reverse DNS, mail-app setup or external delivery. Those acceptance gates remain open on this issue.

  7. 30 remaining items

  8. devantler commented on Nov 13, 2026

    @devantler
    ContributorAuthor

    Steps 1–4 of the outbound relay are live.

    Next:

    🤖 Generated with Claude Code

  9. devantler commented on Nov 13, 2026

    @devantler
    ContributorAuthor

    Outbound relay progress (21:10 UTC).

    🤖 Generated with Claude Code

  10. devantler commented on Nov 13, 2026

    @devantler
    ContributorAuthor

    The SES identity is verified (steps 3, 4 and 7 of the relay table are done).

    • feat(email): publish the SES DNS records through external-dns #6225 merged as 9804da78. Its merge-group deploy succeeded (run 43519410419), and Kyverno admitted the aws/company-mail-ses DNSEndpoint.
    • A public resolver returns all five records: the three DKIM CNAMEs to *.dkim.amazonses.com, plus the MAIL FROM MX and SPF on bounce.devantler.tech. The domain's own MX, SPF and DMARC records are unchanged.
    • A read-only check at 22:58 UTC: the devantler.tech identity in eu-central-1 reports DKIM SUCCESS, verification SUCCESS and verified for sending.
    • The SES production-access case can now be answered. The Set Up SES Account workflow is not re-run while the case is open.

    Next: the relay route (#6236, CI green, review requested), then adopting it in production, then the real delivery test.

    🤖 Generated with Claude Code

  11. devantler commented on Nov 14, 2026

    @devantler
    ContributorAuthor

    The relay route is on main (step 8, first half). #6236 merged as b9aeb4ed after a green CodeRabbit review at 270b86cb, and its merge-group run succeeded. Main published and signed the new setup image (run 43542373401): ghcr.io/devantler-tech/platform-private-mail-bootstrap@sha256:5794c1f16cd13441360a4c508bb72ec1aaa977132c3c7094700ef470fbe5ca93. Its setup sends every remote recipient through SES on 587, requires STARTTLS with a checked certificate, and accepts only a well-formed SES SMTP login. The native fixture proved the stored route on the real server.

    Remaining, in order:

    1. Adopt the image in production (agent). One change sets the digest, adds an ExternalSecret for infrastructure/email/ses-smtp in private-mail, projects relay-username and relay-password into the setup's private inputs, and replaces the egress deny with DNS plus email-smtp.eu-central-1.amazonaws.com:587 only. Production pins the image from fix(email): prepare mailbox permissions without generated roles #5669, so this also adopts fix(email): verify declared administrator role bindings #5788, feat(email): prepare version-aware configuration and recovery #5796, feat(email): prepare Stalwart 1.0.3 for single sign-on #6001 and feat(email): constrain automated company mail submission #6084. It is coordinated with Make company email sign-in, encryption and recovery declarative #5387 before it is opened.
    2. SES production access (maintainer). The identity is verified, so the open AWS case can be answered. Until AWS grants access, the sandbox delivers only to verified recipients.
    3. Real delivery test (agent): SPF, DKIM and DMARC pass, and reply threading is checked. This follows 1 and 2, and needs a sending path through the server.

    🤖 Generated with Claude Code

  12. devantler commented on Nov 14, 2026

    @devantler
    ContributorAuthor

    Production now relays through SES (step 6 of the relay decision is done). #6252 merged as c68df119, and its merge-group deploy succeeded. Read-only checks after the rollout:

    • The Email pod (started 15:12 UTC) runs the signed setup image sha256:5794c1f1… in all three containers. The setup exited 0 with "Email configuration verified; recovery process stopped", so the relay route, its TLS strategy and the outbound routing were applied to the production store and read back.
    • private-mail-relay is SecretSynced from OpenBao. Nobody read the values.
    • The live network policy has no egress deny. Egress is exactly inspected DNS and email-smtp.eu-central-1.amazonaws.com:587.
    • The Email administration route still returns 200 and is accepted by the gateway.

    #5387's unreleased setup changes came with this image. Under the 0.16.27 schema, the setup plan is identical to the previous image's apart from the three relay operations (compared for fresh and existing stores, with and without aliases). They take effect only when a 1.x schema is selected.

    Step 7, real delivery, is still open. It needs a way to send: the server's submission and IMAP ports are not public yet, and the agents' account may only mail the maintainer. It also needs SES production access, or a verified external recipient, while the sandbox is in force. Reply threading can be observed only after the domain's MX moves from iCloud.

    🤖 Generated with Claude Code

  13. devantler commented on Nov 15, 2026

    @devantler
    ContributorAuthor

    Plan for the inbound move: receiving, mail-app access, history and MX.

    Outbound already relays through SES. What remains of this issue is inbound and mail-app access. The server's setup already prepares the three listeners:

    • inbound SMTP on 1025, with STARTTLS;
    • authenticated submission on 1587, with STARTTLS;
    • IMAP on 1993, with TLS from the start.

    The pod still runs in the preparation recovery mode, with only the administration port open. So publishing is mostly wiring.

    One decision first: how the mail ports reach the server. The shared gateway cannot carry inbound SMTP with the sender's address intact. Cilium's TCP and TLS passthrough opens a new connection from Envoy, so the server would see Envoy's address and not the sender's. Inbound SPF, DMARC alignment and abuse limits all need the real address. The options:

    Option Client address Cost Parts
    A. Mail's own Hetzner load balancer (LB11), with PROXY protocol straight to the server (recommended) Kept: the server trusts PROXY only from the load balancer's private network One more LB11, about €6–7.50 a month before VAT (Hetzner's pages differ; the console shows the exact price) One LoadBalancer Service in private-mail
    B. The shared gateway's spare load-balancer slots, as TCP routes Lost None Gateway listeners and TCP routes
    C. The shared load balancer, with a hand-written Envoy listener that adds PROXY upstream Kept None A custom CiliumEnvoyConfig outside the Gateway API, which the gateway route check does not cover

    B breaks inbound authentication, so it is out. A is the simplest working option. I ask before choosing it, because the issue requires its own authorization for any new recurring cost.

    Steps (the agent does everything not marked maintainer):

    # Step Mail effect
    1 Maintainer: choose A or C. —
    2 Certificate for mail.devantler.tech. The server leaves recovery mode with its permanent administrator, opens the three listeners and trusts PROXY only from the load balancer. Publish 25 → 1025, 587 → 1587 and 993 → 1993, and allow them in the network policy. Planned stop, announced in advance: one server restart. Only the administration page is affected, because no mail runs through this server yet.
    3 mail.devantler.tech address records through external-dns. None
    4 Checks from an independent network:
    • the certificate on all three ports
    • IMAP sign-in
    • authenticated submission
    • port 25 refuses relaying
    • 587 refuses mail without sign-in and a sender that does not match the signed-in account
    • the agents' account stays limited to the maintainer
    None
    5 Maintainer, privately:
    • create an app-specific password for the iCloud account and store it in OpenBao at a path I will name;
    • list any other addresses on the domain.
    I never see either.
    None
    6 One reviewed import job copies the iCloud mailbox history into the server and reconciles message counts per folder. iCloud keeps its copy, untouched. None
    7 Maintainer approval at the time: switch devantler.tech's MX to mail.devantler.tech through the DNS owner, with a rehearsed rollback back to iCloud. Announced in advance. Delivery moves. iCloud keeps accepting until the old records expire.
    8 Maintainer: Mac Mail account. Then an external round trip with SPF, DKIM and DMARC passing. None

    I'll start step 2 once step 1 is answered. Steps 2–4 change no DNS or mail routing that is live today.

    🤖 Generated with Claude Code

  14. devantler commented on Nov 15, 2026

    @devantler
    ContributorAuthor

    Step 1 decided: option A. The maintainer approved mail's own Hetzner load balancer, through the coordinating interactive session. His answer to whether mail may get its own LB11, at about €6–7.50 a month before VAT, instead of the free custom setup: "Yes, add it".

    This authorizes this one new recurring cost: a single LB11 for the mail server. It sends PROXY protocol, and the server trusts those headers only from that load balancer.

    Step 2 starts now, and the steps that change the server will be split into small PRs. The server restart in step 2 will be announced in advance, with its expected length.

    🤖 Generated with Claude Code

  15. devantler commented on Nov 16, 2026

    @devantler
    ContributorAuthor

    Steps 2–4 are done: the mail server is published at mail.devantler.tech. MX still points at iCloud, so no external mail arrives here yet.

    PR What Merged (UTC)
    #6373 The setup can trust PROXY headers from one load-balancer address on the three mail listeners, and reads that trust back exactly 16 Nov 00:09
    #6374 The certificate also names mail.devantler.tech 15 Nov 23:54
    #6375 The mail server's own LB11, private-mail: public 167.233.123.140 and 2a01:4f8:c016:43fc::1, private 10.0.1.250 16 Nov 00:28
    #6383 Production adopts that setup with --mail-proxy-source=10.0.1.250 (one restart) 16 Nov 02:42
    #6392 The network policy admits 1025, 1587 and 1993 from 10.0.1.250/32 only 16 Nov 03:21
    #6393 DNS-only A and AAAA records for mail.devantler.tech 16 Nov 03:30

    The one mail stop was announced in advance: about 42 seconds, from 02:34:56 to 02:35:38 on 16 November. The encrypted volume moved nodes with only a brief transient wait, and no recovery was needed.

    Checks from an outside network, sending no message:

    • mail.devantler.tech resolves to both load-balancer addresses on 1.1.1.1 and 8.8.8.8. The certificate verifies by name on 993 (Verify return code: 0) and is valid until 13 February 2027.
    • 993 (IMAPS): TLS from the start and the normal IMAP greeting.
    • 587 (submission): STARTTLS. MAIL FROM before sign-in is refused: 503 5.5.1 You must authenticate first.
    • 25 (inbound): STARTTLS. Relaying to a foreign domain is refused: 550 5.1.2 Relay not allowed.
    • Not yet proven: which client address the server records. Its console log does not include connection addresses at the current trace level. Sessions through the PROXY-sending load balancer behave normally, but the proof comes with step 8: the Received: header of a real message names the connecting address.

    Next, step 5 (maintainer, private). In OpenBao, create the secret infrastructure/email/icloud-history with three keys:

    • username: the iCloud account's Apple ID email address;
    • password: an app-specific password for that account. Create it at appleid.apple.com under Sign-In and Security → App-Specific Passwords, and name it, for example, "Email history copy";
    • addresses: every address on the domain that iCloud receives for, separated by commas, so none is lost when MX moves.

    No agent reads these values. Step 6 adds the reviewed one-time import job, which reads them through an ExternalSecret, copies the history from imap.mail.me.com into the server and reconciles message counts per folder. iCloud keeps its copy. The app-specific password can be revoked as soon as the copy is verified.

    🤖 Generated with Claude Code

  16. added a commit that references this issue on Nov 16, 2026
  17. added a commit that references this issue on Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Fields

Priority

None yet

Start date

None yet

Target date

None yet

Effort

None yet

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions