I'm setting up a Lion server environment for an entire office full of MacBook Pros, all running Lion. Lion server is 10.7.2, running Open Directory, DNS, and Mail. I have successfully set up the mail server to relay mail for two domains. Let's call them domainA and domainB. Everything works if I set it up manually from the Mail client, but I'm trying to use Profile Manager. Now, this requires quite a bit of explanation, so apologies in advance for the long post:

The "Settings for Everyone" profile, when auto-populated via the **"Include configuration for services"** setting in **Server.app > Profile Manager** seems to use the setting from **Server Admin > Mail > General > "Host Name:"**. If I set the hostname to one of the two domain names, the "Settings for Everyone" profile works fine, populates the user's Mail configuration with an address username@domain.com. However, if I use the actual host name for this setting, it populates the email address as username@hostname.domain.com. This is regardless of what is set in the "Domain Name:" setting on the same page. This leaves me with an issue. I can't choose the address / domain the user will use, as it would be defaulted to domainA or domainB via the "Hostname:" setting, not to mention that it just does not seem right to have to use "domain.com" as the hostname, and have DNS records pointed at a mail server. (I would usually point the .domain.com DNS record to a web server, like many domains are set up)

So, I have set up a Group and Group Profile called MailTest, where I have specified the settings for the mail server. I cannot use the "Settings for Everyone" because of the issue I mentioned above, which is why I thought I could just have two profiles, one for each domain. I found [this doc](http://help.apple.com/profilemanager/mac/10.7/#apd073333AA-30C6-4FD2-B2E0-E0C95658A2C4) on Profile Manager variables, and used a few of these to set MailTest up so that it would dynamically configure Mail the way I wanted it. Everything seems to work, EXCEPT for the Email Address setting. 

I have tried using %email% for the Email Address setting, and verifying that the user's OD account has the correct address. When I used %email%, it seems that the **Incoming Mail > Mail Server and Port** setting from the profile is actually used. I also tried using %short\_name%@domain.com, and experienced the same behavior. The only time this setting seems to be recognized is when it is left blank. Then, you are prompted for the email address when installing the profile. 

For those of you that are still with me, has anyone experienced this issue? Are there others that found that they could not use a hostname in the Mail server's settings or else their mail users would have a user@hostname.domain.com address? Does anyone know why the "Email Address" profile setting seems to be overridden by the "Incoming Mail Server" setting?

I can certainly work around this by having multiple Profiles, and by using A records for domain.com that point to my mail server, but this is not desired. I would like to use the %email% variable in my Profile so that I can use a single profile, in hopes of controlling users' email address from their OD account settings.