Skip to content

fix(platform): mirror the IMAP login into the mailbox From - #2924

Merged
Israeltheminer merged 1 commit into
mainfrom
fix/imap-from-address-mirror
Aug 5, 2026
Merged

Israeltheminer merged 1 commit into
mainfrom
fix/imap-from-address-mirror

Conversation

@Israeltheminer

Copy link
Copy Markdown
Contributor

What

An IMAP/SMTP credential had no way to publish its own address. config.fromAddress was read in three places but was never a declared config field, and normalizeConfig rejects undeclared keys — so nothing could ever set it. Every consumer silently degraded:

  • the Inbox header could not name the mailbox a thread belongs to (it fell back to metadata.to)
  • resolveConnectorAccountEmail always fell through to its fallback, weakening sent-mail direction classification
  • the compose sender never resolved, so supportsDynamicSender was dead code

SMTP already derives From from the login username (lib/connectors/natives/imap-smtp.ts), so From and Username are the same value by construction. This declares the field and mirrors it server-side.

Changes

  • connector.yml: declare fromAddress, documented as set automatically from the login.
  • imap_from_address.ts: withImapFromAddress (mirror on write) and storedImapFromAddress (carry an existing mirror).
  • createCredential / updateCredential mirror the username into config. A config replace that omits fromAddress keeps the stored value rather than dropping it — the field is server-owned and never rendered, so a programmatic caller has no way to resupply it.
  • The credential form hides fromAddress: From and Username are one answer, and a second input only invites them to disagree. The value still round-trips through form state, so an edit cannot wipe it.
  • sync_mailbox.ts heals credentials written before the mirror existed — but only when the public config resolves nothing, so the steady state costs one indexed read rather than a credential decrypt per mailbox per sync pass.

Tests

  • imap_from_address.test.ts covers the mirror, the overwrite-on-drift case, the non-email login, other connectors, and the carry-over helper.
  • config-fields.test.tsx keeps its existing coverage (a field per declared setting; nothing at all when none are declared; the declared default stays a placeholder), adds the hidden-field assertion, and adds a round-trip guard proving the hidden value survives an edit.

An IMAP/SMTP credential had no way to publish its own address:
`config.fromAddress` was never a declared field, so `normalizeConfig`
rejected it and nothing could set it. Everything that reads a mailbox's
address therefore fell back or gave up — the Inbox could not say which
mailbox a thread belonged to, and the compose sender never resolved.

SMTP already sends From the login username (`natives/imap-smtp.ts`), so
the two are the same value by construction. Declare the field and mirror
it server-side on create and update; the login is a secret, the From is
not, and the UI needs the public half.

- hide the field on the credential form: From and Username are one
  answer, and a second input invites them to disagree
- carry an existing mirror through a config replace that omits it — the
  field is server-owned and never rendered, so a caller cannot resupply
- heal older credentials on mailbox sync, but only when the public config
  resolves nothing: the steady state costs an indexed read, not a
  credential decrypt per mailbox per pass
@Israeltheminer
Israeltheminer merged commit cb6ce23 into main Aug 5, 2026
50 checks passed
@Israeltheminer
Israeltheminer deleted the fix/imap-from-address-mirror branch August 5, 2026 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant