Skip to content

Keep reply SMTP on the receiving account when sending as another identity - #2875

Open
nitay wants to merge 4 commits into
Foundry376:masterfrom
nitay:up-master
Open

nitay wants to merge 4 commits into
Foundry376:masterfrom
nitay:up-master

Conversation

@nitay

@nitay nitay commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Mailspring currently treats the From address as which account sends the mail. accountForEmail() returns the first primary match, then the first alias, so one address can only belong to one account. Picking the other account's address on a reply calls ensureCorrectAccount(), which moves the draft (and drops threadId) onto that other account's SMTP.

That breaks a normal Gmail send-as setup:

  • Account A (a@gmail.com) can send as B
  • Account B (b@company.com) can send as A

Replying to a B thread as A would silently send through A's SMTP, so the copy never appeared in B's Sent folder. Same in the other direction.

Behavior after this change

Replies stay on the account that received the thread. From is any of the user's identities (every primary and alias, de-duplicated by email). SMTP does not change.

New compose still uses the From picker's contact.accountId (the color-bar row) to choose SMTP. That is how you pick the sending account when there is no thread.

Send validation requires From to be one of the user's addresses (isMyEmail) and draft.accountId to be a configured account. It no longer requires accountForEmail(from) === draft.accountId.

The mail provider still has to allow send-as (Gmail / Workspace "Send mail as"). Mailspring just stops re-homing the draft when it shouldn't.

Code

  • DraftEditingSession.ensureCorrectAccount() — do not switch accounts on a reply; for new compose, honor from.accountId
  • SendDraftTask.willBeQueued() — allow any of the user's identities as From on the draft's account
  • Composer From picker — list every account on replies; de-dupe overlapping addresses only when a threadId is present

Tests

TDD, all green:

  • send-draft-task-spec — sending as another account's primary via this account's SMTP
  • ensure-correct-account-spec — replies never rehome; new compose uses the picked identity's account
  • from-identities-spec + composer-header-spec — reply From list includes other identities and de-dupes

…tity

From is a send-as identity, not a pointer to which account's SMTP to use.
Replies stay on the account that received the thread, so overlapping
aliases work (A sends as B, B sends as A). New compose still uses the
From picker's accountId to choose SMTP.
@nitay
nitay marked this pull request as ready for review September 17, 2026 14:54
@electron/packager 20 auto-discovers mailspring.icon next to the
.icns and compiles it with actool, which requires full Xcode 26+.
Command Line Tools-only machines failed with:

  xcode-select: error: tool 'actool' requires Xcode

Copy the .icns to a temp dir with no sibling .icon so local unsigned
builds still package. CI macOS runners have Xcode and keep the
Liquid Glass catalog.
Replies already send via the receiving account's SMTP. The From dropdown
now matches that: only that account's primary and aliases, not every
configured account. New compose still lists all identities so SMTP can
be chosen.

This branch has not been deployed

No deployments
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