Auto-select sending account based on recipients

The Problem

I have five accounts configured in Mailspring, all for various purposes (a couple business, a few personal of varying degrees of privacy). When I compose a new message it defaults to being sent from my primary account, which is accurate ~50% of the time, but the other 50% I need to remember to switch the From account before sending. I fairly often forget this step, and folks end up receiving email from me from various accounts, which confuses them and mixes up my online identities in general.

Proposed Solution

It’d be great if the compose window would automatically adjust the From account for a message based on the account in which the first entered contact is stored in.

For example, if I have accounts A and B that I send email from (A being the default), and I have a contact X stored in account B, then if I start composing an email to X then it automatically switches the From address to be from account B.

Alternative Solutions

The proposed solution is the most straightforward and deterministic way I can think of this working. But here are some other (more complicated) thoughts that try to account for edge cases too.

Instead of looking at the account that contact is stored in, it could look at which account I most recently emailed this contact from. In some cases, the same contact will appear in more than one account, so that may benefit from the “most recent account” trick.

In other scenarios, I may be emailing a mix of contacts (weird, but could happen). Instead of taking the first recipient and using that for the From account, it could take the most popular one based on all the entered contacts.

Context

Apple Mail.app does this to a certain extent (though I’m not sure what the logic is behind it, sometimes I’m surprised at the choice it makes!).