This is a wrapper around msmtp. It’s written in CHICKEN Scheme 5 which you’d need to compile it.
In ~/.mailcatchrc write lines, each line is a (fake) email address
followed by a space and then a command. And then set your emacs (or
whatever) to mailcatch instead of msmtp.
When you write to email addresses that match those fake email
addresses, that command is run instead of msmtp.
One such example command, mailfedi, is included in the repo so you
can put something like
fediverse@ellen mailfedi
in your ~/.mailcatchrc file. Emails sent to fediverse@ellen are
then sent to the mailfedi command instead. Other email are sent to
msmtp as normal.
git clone https://idiomdrottning.org/mailcatch