I use macOS's Mail app and have iCloud+. I have two mail addresses - my usual iCloud address and another through a custom domain that I own, that maps back to the iCloud account (something which is only possible with iCloud+ )
Incoming mail for both addresses appear in my iCloud inbox. No real problem. When composing outgoing mail I can select the sending address from the drop down in the "From" field. Also no problem.
I have set up two mail signatures, one intended for mail sent from the iCloud address, the other for mail sent from the custom address. When composing, both signatures are available from the "Signature" drop down. All good.
I want to have Mail select the correct signature according to the "From" address. If I change the selected "From" address, the selected signature should also change. Is this possible?
The challenge seems to be that the configuration of Mail, iCloud+ and the custom domain results in Mail thinking that there is only one account (in Mail/Settings/Accounts ) which is the iCloud one. My two signatures are both associated with that one account, although they are intended different for sending addresses. Mail sees that the sending account is iCloud and seems unable to select a signature by sending address.
Is there a way around this using AppleScript or other tool?
In Mail/Settings/Rules I have made the rule:
If From is equal to email@example.com , Run this applescript
tell application "Mail" set theMsg to (get first outgoing message) set message signature of theMsg to signature "albert" end tell
and I have a signature called albert, and another rule and script that should do the same for the custom address.
The script itself works, but Mail's rules seem to be only work on incoming mail and not outgoing.
Result: Neither of the rules and the scripts get triggered.
Is there a way to get mail to run a script on changing the sending address? Or other way to set the signature by sending address?
Mac OS 13.2.1 , Mail 16.0