The email client Microsoft Outlook is supposed to use autodiscover for auto configuration, amongst others described in https://docs.microsoft.com/en-us/previous-versions/office/office-2010/cc511507(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:
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.
Put the following content to index.php
Set ownership
Create alias with custombuild
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).
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 [email protected] 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/autodiscover/autodiscover.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:
<?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).