MacOS – Email addresses contain @HOSTNAME.domain.com when mail is configured using Profile Manager

macosmail.appprofile-managerserver.app

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 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.

Best Answer

Another update... I started fresh with a new install of Lion. Updated to 10.7.3 first, having read about everyone's nightmares after this update.

Anyway, my Kerberos realm is now set to domain1.com, but Profile Manager still insists on using the incoming server name (hostname.domain1.com)as the email address. I tried using both variables, %email% and %short_name%@domain1.com. No luck either way.

What I find aggravating is that if you view the Profile when it is installed, or in Systems Settings > Profiles, the email address is correct. This was also the case before I started over. This leads me to believe that the profiles are somehow not implemented correctly by either Mail or the profile installation process. I looked at the XML in the profile, and do not see any settings that would be responsible for the behavior. Everywhere I used a variable, the resulting values were precisely as I expected.

I again tested the default "Settings for Everyone" profile that is configured automatically based on your server settings, and the Server Admin > Mail > General > "Host name:" setting still takes precedence. So, if you put your actual hostname in this field (i.e. mail.domain.com) your users will all end up using user@mail.domain.com as an address.

I am admitting defeat for now, and just set up A records for domain.com that point to the mail server. This way, I can set my two profiles up, one for each that use domain1.com and domain2.com, respectively, as their incoming servers. The email address will then default to %short_name%@incomingserver