This blog post applies to macOS 12 (Monterey), other versions may differ.
It used to be that setting up a new computer involved the difficult choice of spending hours tweaking settings and trying to remember what arcane incantations were required to obtain the perfect setup, or cloning your old computer and importing years of cruft which quickly removed much of the sheen and speed. To its credit, Apple have been quietly chipping away at the configuration synchronisation for many years now, with Mail settings such as accounts, signatures and rules magically appearing on a new machine when you set it up. Typical of Apple’s slow-but-steady approach, it turns out that for Mail this is actually achieved via iCloud Drive so it is to some extent controllable via the toggle in Preferences➡Apple ID➡iCloud Drive➡Mail.
One reason that developers shy away from synchronisation is that it is a feature fraught with edge cases that make it deceptively hard to do reliably, and unreliable synchronisation is worse than none, at best leading to head scratching frustration and worse, loss of data. This was illustrated to me when my email signatures were failing to appear on a newly configured Mac. I was happy to import them manually but locating the correct place to put them was hard to track down, and iCloud Drive synchronisation meant that it took many attempts to get everything working.
The symptom of the problem was that all my accounts were showing up with 0 signatures. Moreover when I added one manually, it would disappear as soon as I quit Mail. iCloud Drive appeared to be working correctly, with all my other files present. In hindsight I suspect the download process was stuck but iCloud remains frustratingly opaque to troubleshoot and when even a reboot could not persuade the missing files to appear, it was time to attempt surgery.
Confusingly, Mail configuration is stored in multiple places. After much trial and error, my conclusion is that the iCloud synchronised files live in
Library/Mobile\ Documents/com\~apple\~mail/Data/V4/Signatures/ (all paths relative to your home directory unless otherwise stated). However adding files to this directory did not fix the problem and at one point I tried deleting this directory and that deletion synchronised to another computer–be warned ⚠️ (Thank goodness for Time Machine backups.)
I was finally able to make signatures work again on the errant Mac by shutting down Mail, and then adding them to
Library/Mail/V9/MailData/Signatures/. I believe I also disabled Mail in iCloud Drive but then I restored it afterwards and it did not complain. However on the second Mac where iCloud Drive copied down bad data, any files added to
Library/Mail/V9/MailData/Signatures/ were removed the next time Mail started if Mail was enabled in iCloud Drive. Trying to convince iCloud this was a file newer than the server copy by editing the .plist file did not work. This was eventually fixed by copying the contents of
Library/Mobile\ Documents/com\~apple\~mail/Data/V4/Signatures/ and re-enabling Mail in iCloud Drive.
And so our tale of synchronisation woe has a happy ending. Credit to Apple for continuing to use text files for configuration, the ability to manipulate these via the terminal and easily restore them from a Time Machine backup were crucial to the successful outcome.