Autodiscover is a service that allows email clients to automatically determine a user’s mail server address and port from that user’s email address and password alone. This greatly simplifies a user’s setup process when attempting to connect SmarterMail to a desktop client, like Outlook and Windows Mail, as well as mobile clients on their iPhone, iPad, Android, Windows Phone and other mobile devices.
Autodiscover is supported by POP, IMAP, SMTP In, MAPI/EWS and EAS. However, not all email clients handle Autodiscover in the same way. For example, when connecting SmarterMail to mobile devices, only EAS connections will use Autodiscover. Outlook 2007 and above will return only IMAP connections. The Windows Mail client will return EAS, and while Thunderbird does not support Autodiscover at all, it will make the best effort to connect to any mail server. Because each client handles Autodiscover differently, it’s important to review the support documentation of your users’ preferred email client(s) to learn the connection type that’s best suited.
NOTE: Utilizing Autodiscover with MAPI/EWS or EAS requires encryption over SSL or TLS. Therefore, port 443 MUST be available and not blocked by a firewall. For instructions on this configuration, please see Configure SSL/TLS to Secure SmarterMail.
To configure Autodiscover for a SmarterMail domain, a SmarterMail Administrator must perform the following:
- Configure the domain’s Autodiscover settings within SmarterMail
- Create an A Record for the domain in the DNS configuration
- Create an SRV Record for the domain in the DNS configuration
- Create an IIS binding for Autodiscover on the SmarterMail server
- Configure an IIS rewrite rule*
*This is only necessary if your SmarterMail site starts with a subdomain, and a website on a different server uses that same domain name.
Configure the Domain’s Autodiscover Settings within SmarterMail
Follow these steps to adjust the protocols enabled for Autodiscover and the ports on which they listen:
- Log in to SmarterMail as a system administrator.
- Click on the Manage icon. In the Domains section, click on a domain to open its configuration settings.
- On the Options card, ensure the correct Hostname is entered. The hostname is the URL that will be returned when users attempt to connect to their email client. The most common hostname for a mail URL is “mail.yourdomain.com”.
- On the Autodiscover card, adjust the configuration options as needed. Here, you can enable or disable specific protocols from returning Autodiscover results. When a protocol is enabled for Autodiscover, clicking on that protocol’s settings cog will open a window where the encryption type and port can be adjusted. (EAS and EWS require encryption over SSL/TLS and this configuration cannot be modified.) NOTE: If a user has POP disabled for their account, their POP Autodiscover request will not be fulfilled, even if POP is enabled for Autodiscover. This applies to all protocols in their account's Service Access settings.
Modifying the Default XML Response (optional)
NOTE: The Override Desktop XML and Override Mobile XML options should NOT be modified without advanced knowledge of the XML responses used with Autodiscover. Adjusting the custom XML incorrectly can result in invalid responses returned meaning users will be unable to connect to their email client(s).
Administrators with advanced Autodiscover knowledge can override the default XML response that is sent from the domain when Autodiscover is requested. There are two types of Autodiscover responses that can be modified: Mobile XML and Desktop XML. The mobile XML response is strictly used with Exchange ActiveSync. The desktop XML response is used with everything else, including IMAP, POP, SMTP In and Exchange Web Services.
Follow these steps to override the desktop or mobile XML response sent by SmarterMail:
- Enable Override Desktop XML or Override Mobile XML.
- Click on the textbox that appears for Custom Desktop XML or Custom Mobile XML.
- In the textbox window that appears, clicking on Generate will show the XML response that SmarterMail would normally send on an Autodiscover request. You can generate this response to make adjustments as needed, or simply enter the XML response you would like to use.
- NOTE: If you turn on an override but never save any custom XML, SmarterMail will use the default protocol settings. However, if the override is turned on, ANY text you save to the Custom XML area will be used for the Autodiscover response. If you save custom text, then later remove that text and save a blank entry, Autodiscover will send a blank response. Therefore, it is imperative that you only enable the override and enter custom Autodiscover XML if you are absolutely sure what you're using is correct.
Other items to note:
- You can adjust the XML reply as needed. However, don’t remove or modify these variables:
- %EmailAddress%
- %Base64EmailAddress%
- %DisplayName%
- %LegacyDN%
- The above variables are used to identify the user making the Autodiscover request. (%Base64EmailAddress% is used in SmarterMail version 17.x and higher.)
- Any changes made to the XML response should be within the RFC guidelines, though this is not validated by SmarterMail.
Create an A Record for the Domain in the DNS configuration
For Autodiscover to work, each domain needs an A Record for "autodiscover.yourdomain.com" that points to the IP address of your mail server. For example, for SmarterTools, we set up an A Record for "autodiscover.smartertools.com" that points to the IP address of our mail server (mail.smartertools.com). In our DNS, the line in our zone file for this A Record looks like this:
autodiscover IN A 69.71.61.105
There are many ways to manage DNS for a domain, as well as many DNS services that can be used, so providing step-by-step instructions on this configuration is difficult. However, adding a record should be fairly straightforward. If you have questions, contact your IT professional, hosting provider or DNS provider for assistance.
Create an SRV Record for the Domain in the DNS configuration
Next, you'll want to create an SRV record for your domain. This SRV Record will return the available domain and service (SMTP, POP or IMAP) to the email client requesting Autodiscovery. Technically, setting up an SRV Record is an optional step; however, it is highly recommended as a backup to ensure Autodiscover works properly.
The SRV Record that is created should be in the following format and return the root URL of your email server:
_autodiscover._tcp.(your domain)
There are many ways to manage DNS for a domain, as well as many DNS services that can be used, so providing step-by-step instructions on this configuration is difficult. Please check with your IT professional, hosting provider or DNS provider for instructions on configuring an SRV Record for your environment. The following example details the SRV configuration for SmarterTools:
Domain: smartertools.com
Service: _Autodiscover
Protocol: _tcp
Priority: 0
Weight: 0
Port: 443
Verify the SRV via NSLookup (optional)
Follow these settings to verify that you have set up the SRV Record correctly:
- On a Windows machine, open the Command Prompt and do the following:
- Type NSLOOKUP and press ENTER.
- Type set type=srv and press ENTER.
- Type _autodiscover._tcp.yourdomain.com, where "yourdomain.com" is the name of your domain, and press ENTER.
In return, you should get something similar to what's shown below, with the IP addresses and server URLs matching what you have set up for your mail server. If your results differ or no results are returned, please review your DNS configuration. It's possible the issue is caused due to DNS caching or replication.
Server: UnKnown Address: 127.0.0.1 Non-authoritative answer: _autodiscover._tcp.your-domain.com SRV service location: priority = 0 weight = 0 port = 443 svr hostname = mail.your-domain.com mail.your-domain.com internet address = 127.0.0.2
Create an IIS binding (Host Header) for Autodiscover on the SmarterMail Server
In IIS, a host header for Autodiscover should be added to your SmarterMail website that points your Autodiscover A Record to your SmarterMail installation. For example, for SmarterTools, we have an IIS binding that binds port 80 and 443 to "autodiscover.smartertools.com." This is added in addition to the IIS binding for "mail.smartertools.com", which is the URL used for setting up email clients and accessing the web interface.
If your SmarterMail installation is on a * binding and listens for any host header, you'll just need to add the necessary DNS records. However, if host headers are used for each domain, a host header must be added for each domain for both Autodiscover and webmail.
To learn how to configure a host header in IIS, please review Microsoft’s documentation. After the IIS binding has been configured, perform an IIS reset.
Configure an IIS rewrite rule
NOTE: This step is only necessary if your environment matches what's described below. If you do not have a company website that uses the same domain as your mail server subdomain, you may skip this step.
If your SmarterMail site starts with a subdomain (such as mail.yourdomain.com), and a website on a different server uses that same domain name (ex: yourdomain.com), an IIS rewrite is required in order to help the Autodiscover process find the correct server. For example, here at SmarterTools, we have a server that hosts our company website which points to smartertools.com. On a different server, we host our SmarterMail installation which points to mail.smartertools.com. SmarterMail users are configured with email addresses in the format user@smartertools.com.
This issue we've found is that some Autodiscover clients will take the user's email address and do an Autodiscover lookup based on the domain, smartertools.com. This lookup will send the Autodiscover request to the server that hosts the company website, not the server that hosts the SmarterMail installation. Adding an IIS rewrite rule on the server that hosts the company website helps to prevent this issue.
To configure the URL Rewrite, you can either: Create a Rewrite Rule within IIS OR add the rewrite parameters to the site's web.config file.
Create a URL Rewrite within IIS
Follow these steps if you'd like to add the rewrite rule by creating a URL Rewrite within IIS:
(Note: These instructions are for IIS 10. Steps may vary when using a different version of IIS.)
- Log in to the server that hosts your company website.
- Install the extension, URL Rewrite Module 2.0. For assistance and more information, see Using URL Rewrite Module 2.0.
- After the URL Rewrite Module has been installed, open Internet Information Services (IIS) Manager.
- In the navigation pane, expand the server name folder and Sites folder. Click on the site that's used for your company website.
- In the preview pane that lists the site features, under the IIS section, double-click on URL Rewrite.
- In the righthand Actions pane, click on Add Rules....
- Under the Inbound rules section, click on Blank rule.
- The Edit Inbound Rules window should be modified with the following parameters:
- Name: Redirect rule1 for /autodiscover/autodiscover.xml
- Requested URL: Matches the Pattern
- Using: Regular Expressions
- Pattern: .*
- Ignore case: Enabled
- Conditions
- Logical Grouping: Match All
- Click Addto create a new condition:
- Condition Input: {/autodiscover/autodiscover.xml:{REQUEST_URI}}
- Check if input string: Matches the Pattern
- Pattern: (.+)
- Click OK to submit the new condition.
- Track capture groups across conditions: Disabled
- Server Variables: None
- Action
- Action Type: Redirect
- Action Properties
- Redirect URL: {C:1}
- Append query string: Disabled
- Redirect type: Permanent (301)
- In the righthand pane, click Apply to save the Inbound Rule.
- After the Inbound Rule has been configured, perform an IIS reset.
Add the rewrite parameters to the web.config file
Follow these steps if you'd like to add the rewrite rule by modifying the company website's web.config file:
- Log in to the server that hosts the company website.
- Navigate to the company website's web.config file. (The location of the web.config file can vary but is typically found under your IIS directory.)
- Edit the web.config file (using a text editor or, ideally, something like SublimeText that preserves formatting) and add the following parameters to the system.webServer sections. Don't forget to replace the URL, https://mail.DOMAIN.com/autodiscover/autodiscover.xml, with your own mail server domain.
<system.webServer>
<rewrite>
<rewriteMaps>
<rewriteMap name="/autodiscover/autodiscover.xml">
<add key="/autodiscover/autodiscover.xml" value="https://mail.DOMAIN.com/autodiscover/autodiscover.xml" />
</rewriteMap>
</rewriteMaps>
<rules>
<rule name="Redirect rule1 for /autodiscover/autodiscover.xml">
<match url=".*" />
<conditions>
<add input="{/autodiscover/autodiscover.xml:{REQUEST_URI}}" pattern="(.+)" />
</conditions>
<action type="Redirect" url="{C:1}" appendQueryString="false" />
</rule>
</rules>
</rewrite>
</system.webServer> - After saving the changes to the web.config file, perform an IIS reset.
Once all of these steps have been configured, users can sync their SmarterMail account to any email client that supports Autodiscover using only their email address and password. SmarterMail will take care of the rest!
TROUBLESHOOTING
Here are a few things to test to ensure things are set up correctly. If one or more of these fail, you will need to fix those issues before troubleshooting further.
- In a browser, navigate to https://mail.your-domain.com. This should resolve successfully to the SmarterMail web interface and without SSL or other errors.
- Navigate to https://autodiscover.your-domain.com. This should resolve successfully to the SmarterMail web interface and without SSL or other errors.
- Navigate to https://your-domain.com/autodiscover/autodiscover.xml. These requests should be redirected to https://mail.your-domain.com/autodiscover/autodiscover.xml so that SmarterMail handles the request.
- Check DNS for your-domain.com. It should contain an SRV record that references mail.your-domain.com on port 443 to avoid certificate errors due to hostname mismatches and the like.