Continuing on from yesterday’s post, today I’ll detail a seemingly little known feature of Apple’s Mail.app in 10.5 and after (pretty sure it doesn’t support 10.4).
Anyone who has set up a gmail account in Mail.app knows that once you put in your email address “[email protected]” and a password, it just magically figures out the mail servers, sets SSL, and you’re good to go. What you may NOT know, is that you can make Mail.app do this for your customers when they put in their email address for your system.
The process is pretty easy. What you need to do is create a file called MailAccounts.plist, in that file, you put something like the following:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Multiple</key> <array> <dict> <key>Accounts</key> <array> <dict> <key>AccountID</key> <string>A3734534-8712-4151-BF69-8E477D0873CE</string> <key>AccountName</key> <string>EXAMPLE</string> <key>AuthenticationScheme</key> <array> <string>Password</string> </array> <key>DeliveryAccounts</key> <array> <string>5043D409-F857-4D74-A252-3820A4F43CEF</string> </array> <key>EmailAddressDomain</key> <string>@mail.example.com</string> <key>Protocol</key> <string>IMAP</string> <key>ServerName</key> <array> <string>mail.example.com</string> </array> <key>SSLEnabled</key> <true/> <key>UserNameMatchesEmailAddress</key> <true/> </dict> <dict> <key>AccountID</key> <string>5043D409-F857-4D74-A252-3820A4F43CEF</string> <key>AccountName</key> <string>EXAMPLE</string> <key>AuthenticationScheme</key> <array> <string></string> </array> <key>Protocol</key> <string>SMTP</string> <key>ServerName</key> <array> <string>mail.example.com</string> </array> </dict> </array> <key>Identifier</key> <string>com.example.mail</string> <key>Version</key> <integer>1</integer> </dict> <dict> <key>Accounts</key> <array> <dict> <key>AccountID</key> <string>BB65656D-6A91-4218-93C8-1A7DA1C8A9B9</string> <key>AccountName</key> <string>EXAMPLE2</string> <key>AuthenticationScheme</key> <array> <string>Password</string> </array> <key>DeliveryAccounts</key> <array> <string>7BBCA82B-EFDD-4EB5-8CCD-1972D64852AF</string> </array> <key>EmailAddressDomain</key> <string>@example.com</string> <key>Protocol</key> <string>IMAP</string> <key>ServerName</key> <array> <string>imap.example.com</string> </array> <key>SSLEnabled</key> <true/> <key>UserNameMatchesEmailAddress</key> <true/> </dict> <dict> <key>AccountID</key> <string>7BBCA82B-EFDD-4EB5-8CCD-1972D64852AF</string> <key>AccountName</key> <string>EXAMPLE2</string> <key>AuthenticationScheme</key> <array> <string></string> </array> <key>Protocol</key> <string>SMTP</string> <key>ServerName</key> <array> <string>smtp.example.com</string> </array> </dict> </array> <key>Identifier</key> <string>com.example.mail2</string> <key>Version</key> <integer>1</integer> </dict> </array> </dict> </plist>
The key bits in there, and what aren’t explained at all in the Apple documentation on this, are those UUID’s. Basically, the “first” one for each section defines the whole account section, and should be unique in the file. The 2nd and 3rd UUIDs are the same (e.g. 2nd and 3rd UUID are the same, but different than the 1st UUID). Creating those UUIDs is a simple matter of running “uuidgen” from the command line of 10.5 or above (probably exists in 10.4). Also notice, I’ve got two completely “dicts” in here. In my setup, this is because I have it autoconfiguring mail settings for people with campus email addresses, as well as settings for people that have department email addresses. You can safely remove the second “stanza” (everything below the version 1 key, and the “dict” below it, and the corresponding second to last “dict” at the end of the file).
You’ll want to go through and replace the incoming and outgoing mail servers, as well as the email address piece (this is how Mail.app sees to use these settings).
Once you’ve made your changes, you’ll want to save this file in /Library/Mail/AccountTypes/tld.example/. AccountTypes probably won’t exist, so create it. The “tld.example” would be in typical reverse FQDN format (as seen in most OS X files), but ultimately, it can be anything you want (naming it in RFQDN is just a good way to know who created the file).
Save it all, and give it a try in Mail.app (after restarted it). You should be able to enter your email address like [email protected], and mail will automatically populate the incoming, and outgoing mail servers, set SSL, etc.
To see other keys that you can set, refer to the Apple documentation here.
nate says
interesting. i didn’t know about that one. my testing just now didn’t work, though. does the bundle have to be a real bundle with bundle bit set, etc.?
i should probably test with a simpler domain… the one i’m using has postini defined as primary mx, not the actual mail server.
staze says
No bundle bit. It’s just a plain old folder/directory.
Let me know if you need some more help.