Where does Mail.app store the email addresses/aliases for your own accounts?

I'm trying to programatically access the email addresses configured in Mail.app. I looked through defaults read com.apple.mail but they don't appear there. I also had a look in sqlite3 ~/Library/AccountsAccounts4.sqlite, but similarly had no luck.

I'd LOVE to be able to change/append to them programatically, but it would also be useful to just be able to READ what's there.


Solution 1:

AppleScript has objects for managing mail accounts. They provide a programatic way of reading and creating accounts. Once you get it working it will be more robust than reading and writing using defaults or sqlite3.

I don't have first hand experience but a web search gave me these links:

  • Displaying mail account information with AppleScript
  • Creating an account and sending mail using applescript

Here is the dictionary entry for the account object:

Mail account in AppleScript

The examples in the links should give you a start into developing your own solutions in AppleScript.