iRedMail Easy: Setup DNS records for autoconfig and autodiscover

Attention

Check out the lightweight on-premises email archiving software developed by iRedMail team: Spider Email Archiver.

iRedMail Easy offers component Autoconfig and Autodiscover to help end users setup their MUA like Thunderbird and Outlook which supports autoconfig and autodiscover protocol.

This tutorial explains how autoconfig and autodiscover works, and how to setup required DNS records to get them working. In this tutorial, we use:

How autoconfig works in Thunderbird

To setup email account user@customer.com, Thunderbird performs the lookups below in particular order to get pre-defined server settings:

  1. It checks http://autoconfig.customer.com/mail/config-v1.1.xml?emailaddress=user@customer.com
  2. if failed, checks http://customer.com/.well-known/autoconfig/mail/config-v1.1.xml?emailaddress=user@customer.com
  3. If failed, try to find the config of mail domain at the Mozilla ISP database (ISPDB).

    For more details about ISPDB, or you're a big ISP and want to add your domain in ISPDB, please read this tutorial.

  4. Look up DNS MX record of customer.com. If the server specified in DNS MX record is mx1.mail.host.com, look up host.com in the ISPDB.

  5. If all mechanisms failed, Thunderbird tries to guess the server address, by trying common server names like imap.customer.com, smtp.customer.com, mail.customer.com, etc. and, when a mail server answers, checking whether it supports SSL, STARTTLS and encrypted passwords (CRAM-MD5).

We don't control Mozilla ISPDB, and most times web site is hosted on another server, so the ideal solution is setting DNS record autoconfig.customer.com and pointed to your mail server. We will show you how to setup this DNS record later.

The autoconfig component configured by iRedMail Easy supports URLs:

How auto-discover works in Microsoft Outlook

Warning

Outlook requires a valid ssl cert, a self-signed ssl cert may fail.

Without Microsoft Exchange, the order of logic that Outlook 2007 and newer releases use when trying to figure out where to get server settings is as follows:

  1. HTTPS root domain query. Outlook uses the domain part of user email address to do this query, so it's https://customer.com/autodiscover/autodiscover.xml.
  2. If above failed, try HTTPS autodiscover domain: https://autodiscover.customer.com/autodiscover/autodiscover.xml.
  3. If above failed, try same URL but HTTP instead: http://autodiscover.customer.com/autodiscover/autodiscover.xml
  4. If all failed, try DNS SRV record: _autodiscover._tcp.customer.com. If it returns a web host name and port number, for example, mail.host.com and port number 443, then try https://mail.host.com:443/autodiscover/autodiscover.xml

The ideal solution is setting DNS SRV record _autodiscover._tcp.customer.com and point to your server mail.host.com.

The autodiscover component configured by iRedMail Easy supports URLs:

Setup DNS record for autoconfig

Please create either a DNS A or CNAME record autoconfig.customer.com for your customer's domain name:

After created, you may need to wait for 2 or more hours until your DNS vendor flush the DNS cache. Then you can test the autoconfig with curl commands below:

curl -k http://autoconfig.customer.com/.well-known/autoconfig/mail/config-v1.1.xml?emailaddress=user@customer.com
curl -k http://mail.host.com/mail/config-v1.1.xml?emailaddress=user@customer.com
curl -k http://mail.host.com/.well-known/autoconfig/mail/config-v1.1.xml?emailaddress=user@customer.com

It should print a XML format content on console.

Setup DNS record for autodiscover

Please create a DNS SRV record for your customer's domain name customer.com:

Outlook will query DNS SRV record _autodiscover._tcp.customer.com first, then fetch pre-defined server settings from URL https://mail.host.com/autodiscover/autodiscover.xml.

After created, you may need to wait for 2 or more hours until your DNS vendor flush the DNS cache. Then try to query it with dig command like below:

# dig +short -t srv _autodiscover._tcp.customer.com
1 1 443 mail.host.com.

Create temporary text file /tmp/outlook.xml with content below:

<?xml version="1.0" encoding="utf-8" ?>
<Autodiscover xmlns="http://schemas.microsoft.com/exchange/autodiscover/outlook/requestschema/2006">
    <Request>
        <AcceptableResponseSchema>http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a</AcceptableResponseSchema>

        <!-- EMailAddress: indicates the user's email address. OPTIONAL -->
        <EMailAddress>user@customer.com</EMailAddress>
    </Request>
</Autodiscover>

Create temporary text file /tmp/eas.xml with content below:

<?xml version="1.0" encoding="utf-8"?>
<Autodiscover xmlns="http://schemas.microsoft.com/exchange/autodiscover/mobilesync/requestschema/2006">
    <Request>
        <EMailAddress>user@customer.com</EMailAddress>
        <AcceptableResponseSchema>http://schemas.microsoft.com/exchange/autodiscover/mobilesync/responseschema/2006</AcceptableResponseSchema>
    </Request>
</Autodiscover>

Now run curl commands to verify it:

curl -k -X POST -d @/tmp/outlook.xml https://autodiscover.customer.com/autodiscover/autodiscover.xml
curl -k -X POST -d @/tmp/eas.xml https://autodiscover.customer.com/autodiscover/autodiscover.xml

curl -k -X POST -d @/tmp/outlook.xml https://mail.host.com/autodiscover/autodiscover.xml
curl -k -X POST -d @/tmp/eas.xml https://mail.host.com/autodiscover/autodiscover.xml

It should print XML format content on console.