Results 1 to 4 of 4

Thread: Guide for autodiscover

  1. #1
    Join Date
    Jul 2019
    Posts
    7

    Guide for autodiscover

    The email client Microsoft Outlook is supposed to use autodiscover for auto configuration, amongst others described in https://docs.microsoft.com/en-us/pre...7(v=office.14).

    Our solution is based on the solution given by https://github.com/smartlyway/email-autoconfig-php with some minor tweaks.

    With our solution autodiscover is put on each domain, and hence there is no need for a DNS SRV record. From the Microsoft article above:

    Autodiscover in Outlook 2010 is an XML file that is put in one of two locations, based on the domain name provided by the user. For the Internet, Autodiscover relies on the Domain Name System (DNS) to find the XML file. The XML file location is based on the e-mail address that the user provides. For example, if barbara@contoso.com is entered as the user’s e-mail address, Outlook 2010 looks for the XML file in the following locations and in the following order:

    1. https://contoso.com/autodiscover/autodiscover.xml

    2. https://autodiscover.contoso.com/aut...todiscover.xml

    If your company also has a Web site at the root domain (for example, contoso.com), the second option (the Autodiscover “host (A) resource record” solution) lets you run the Web server and the Autodiscover file or service on separate servers. For smaller companies, the additional management of having separate DNS records can be ignored, and a single server can run both the Web site and the Autodiscover service (for example, the option 1 listed previously).
    We have chosen option 1 above.

    Start to create Autodiscover.xml. Since data will be posted to it, we use the trick to create Autodiscover.xml as a directory and put an index.php file there.

    Code:
    mkdir -p /var/www/html/Autodiscover/Autodiscover.xml
    cd /var/www/html/Autodiscover/Autodiscover.xml
    vi index.php
    Put the following content to index.php

    PHP Code:
    <?php
    // Report simple running errors
    error_reporting(E_ERROR E_WARNING E_PARSE);

    $raw file_get_contents('php://input');
    $matches = array();
    preg_match('/<EMailAddress>(.*)<\/EMailAddress>/'$raw$matches);
    $email $matches[1];

    if (!
    filter_var($email,FILTER_VALIDATE_EMAIL)){
            
    // plonk, no remorse
            
    die();
    }

    list(
    $user,$domain) = preg_split("/@/",$email,2);

    header('Content-Type: application/xml');
    ?>
    <Autodiscover xmlns="http://schemas.microsoft.com/exchange/autodiscover/responseschema/2006">
      <Response xmlns="http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a">
        <User>
          <DisplayName><?=$email?></DisplayName>
        </User>
        <Account>
          <AccountType>email</AccountType>
          <Action>settings</Action>
          <Protocol>
            <Type>IMAP</Type>
            <Server>mail.<?=$domain?></Server>
            <Port>993</Port>
            <DomainRequired>off</DomainRequired>
            <SPA>off</SPA>
            <SSL>on</SSL>
            <AuthRequired>on</AuthRequired>
            <LoginName><?=$email?></LoginName>
          </Protocol>
          <Protocol>
            <Type>SMTP</Type>
            <Server>mail.<?=$domain?></Server>
            <Port>587</Port>
            <DomainRequired>off</DomainRequired>
            <SPA>off</SPA>
            <SSL>on</SSL>
            <AuthRequired>on</AuthRequired>
            <LoginName><?=$email?></LoginName>
          </Protocol>
        </Account>
      </Response>
    </Autodiscover>
    Set ownership

    Code:
    cd /var/www/html/Autodiscover
    chown -R webapps.webapps .
    Create alias with custombuild

    Code:
    cd /usr/local/directadmin/custombuild
    echo 'Autodiscover/Autodiscover.xml=Autodiscover/Autodiscover.xml' >> custom/webapps.list
    ./build rewrite_confs
    Now to test this, create an email account on the server and go to
    https://testconnectivity.microsoft.com/ to test it, see this image https://xxa.se/i/10n123m.png

    Our implementation did pass the test. But, when I tested with the latest Outlook version on both Windows and MacOS, it never used autodiscover. Outlook did however find the proper settings very fast. It decided to use SSL on 465 and 993. Our TB autoconfig, thread Thunderbird:Autoconfiguration , has set TLS as the preferred settings. Hence Outlook does not use that method either to decide the settings.

    So, the bottom line, I am not sure what the value is to implement autodiscovery. I guess it used for active sync, but we do not offer it and the xml scheme is very different from the above (hence activesync tests will fail).

  2. #2
    Join Date
    Apr 2005
    Location
    GMT +7.00
    Posts
    13,579
    Hello,

    The last time I've tried the newest Office 365 I've found out it very tricky to get working with a custom hosted autodiscover. All tests are passing fine, and still in certain cases autodiscover failed for some domains. In logs I found IPs from Microsoft Network, so it seems they somehow proxy requests and it add some difficulties.

    So in your case it might be not that XML file is wrong, you might need to dig it further and check logs.
    Regards, Alex G.

    - Get the best commercial DirectAdmin support and hire me on poralix.com
    - Follow and like @Poralix on Facebook

  3. #3
    Join Date
    Jul 2019
    Posts
    7
    Quote Originally Posted by zEitEr View Post
    So in your case it might be not that XML file is wrong, you might need to dig it further and check logs.
    I have put debug code in the index.php file and it is never called by neither outlook nor microsoft, when I config Outlook. The tests on https://testconnectivity.microsoft.com/ do however post to the index file.

  4. #4
    Join Date
    Apr 2005
    Location
    GMT +7.00
    Posts
    13,579
    That's what I faced too, I did not find any logic in new software versions from Microsoft. And their documentation I've found does not enlighten it.
    Regards, Alex G.

    - Get the best commercial DirectAdmin support and hire me on poralix.com
    - Follow and like @Poralix on Facebook

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •