Add to Favourites Add to Favourites    Print this Article Print this Article

Autodiscover information for mail clients to setup pop/imap/smtp settings automatically.

Some mail clients will use a system called "Autodiscover" to figure out which settings to use for the pop/imap/smtp settings.

You can set this up if you'd like, it basically requires a subdomain and a SRV record.
You can add the SRV record into any domain you want to use these settings for.
If you've got a global SSL certificate in exim/dovecot for your hostname, this would be a good way to ensure clients use the correct value, so they don't get SSL certificate errors.

Let's assume you're going to have your clients with connect to for both IMAP and SMTP.
We'll create a subdomain called to store the XML.

  1. Setup a SRV record in the clientdomain.com DNS zone:

    _autodiscover._tcp.clientdomain.com. 3600 IN SRV 10 10 443 autodiscover.hostname.com.

  2. Next, create the subdomain autodiscover.hostname.com in DA, and add the following code into a file called autodiscover.php:

    //get raw POST data so we can extract the email address
    $data = file_get_contents("php://input");
    preg_match("/\
    //set Content-Type
    header("Content-Type: application/xml");
    echo '
                                                                                   server.hostname.com                                                                                                                                                        server.hostname.com                                                                                                                                                        server.hostname.com                                                                                                                                                         Note that the SRV record is using port 443 for autodiscover.hostname.com, so make sure you've got a valid certificate setup for this subdomain.
    You can test by going to a https://autodiscover.hostname.com to ensure you get a green lock.  The script is looking for XML input in the
    If needed, you can set SMTP to use port 465, but you'd have to change the Port 587 requires smtp-auth but skips some spam checks and uses STARTTLS to enable SSL.  Port 465 is full SSL but clients might have issues sending if their IP/range is in an RBL.

  3. Lastly, we'll need to setup an .htaccess file so that any request to the autodiscover.hostname.com subdomain results in the autodiscover.php being called.   In the subdomain's DocumentRoot, add this code:

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} -s [OR]
    RewriteCond %{REQUEST_FILENAME} -l [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^.*$ - [NC,L]
    RewriteRule ^.*$ autodiscover.php [NC,L]




Thunderbird

Unlike Microsoft auto-detect, Thunderbird does a direct attempt on

http://autoconfig.clientdomain.com/mail/config-v1.1.xml?emailaddress=user@domain.com

This can be handled by creating a subdomain called "autoconfig", and in the web-area for this subdomain, create a folder called "mail", and inside this "mail" directory, create a file called config-v1.1.xml.   A sample path in the File Manager might look like:

/domains/clientdomain.com/public_html/autoconfig/mail/config-v1.1.xml

Inside this file, place the code:

 clientdomain.com">
   clientdomain.com              clientdomain.com                                      clientdomain.com                              


Was this answer helpful?

Also Read