feat: reply from the address a message was delivered to - #278
Open
salmonumbrella wants to merge 1 commit into
Open
feat: reply from the address a message was delivered to#278salmonumbrella wants to merge 1 commit into
salmonumbrella wants to merge 1 commit into
Conversation
Capture the envelope recipient (Delivered-To / X-Delivered-To / X-Original-To / Envelope-To) at ingest into messages.delivery_addresses and let reply alias auto-selection match it first, so a message that reached an alias through BCC or a catch-all replies from that alias even though the alias never appears in To/Cc. Selection stays transient -- nothing is auto-created or persisted. Existing messages carry NULL and keep today's behavior; a later re-sync backfills them. The send path is untouched: the matched alias flows through the existing aliasId mechanism. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Jul 16, 2026
salmonumbrella
marked this pull request as draft
July 16, 2026 10:47
salmonumbrella
marked this pull request as ready for review
July 16, 2026 10:53
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
When a message arrives at an alias through a BCC delivery or a catch-all, the alias never appears in To/Cc — so the existing reply alias auto-selection (which matches To/Cc/From against the account's aliases) misses, and the reply comes from the primary address. This follows up on the #256 discussion: "MailFlow doesn't yet auto-select the alias a message was delivered to when you hit reply."
This PR captures the envelope recipient (
Delivered-To/X-Delivered-To/X-Original-To/Envelope-To) at ingest and lets the reply alias matcher check it first, ahead of To/Cc/From. Selection stays transient — nothing is auto-created or persisted into aliases, per the direction in #256. Existing messages carry no capture (NULL) and behave exactly as today, then backfill on their next sync touch; the send path is untouched — the matched alias flows through the existingaliasIdmechanism.Changes
messages.delivery_addresses JSONB, same shape aslist_unsubscribemessageParser.js:parseDeliveryAddresses()reads the four delivery headers from the already-parsed header map (reusesparseMailboxList; no IMAP fetch changes), deduped and capped at 50 addresses (sender-controlled input, capped like subject/snippet)imapManager.js: persists the parsed addresses at the message INSERT sites with the sameCOALESCEupsert plumbing aslist_unsubscribe(the synthesized sent-copy record has no delivery headers and is deliberately left out)messageService.js+mail.js: exposedelivery_addresseson the message shapes the frontend actually replies from (list, thread, single message, resolve)MessagePane.jsx: the inline reply-alias matcher is extracted tofrontend/src/utils/replyAlias.js(pure, testable) and now checks delivery addresses first; the existing To/Cc/From matching semantics — including the alias-creation-order tiebreak for multi-alias accounts — are preserved bit-for-bit and pinned by testsTesting
--max-warnings 0) — new parser cases: repeated/multi-line headers, angle-bracket forms, cross-header dedupe, junk lines, the size capContributor License Agreement
By submitting this pull request I confirm that:
third-party material and confirmed it is compatible with the CLA).