Om autodiscover mogelijk te maken voor emailclients dient er e.e.a. ingericht te worden.
Er zal een DNS record moeten worden aangemaakt en daarnaast moet er een xml bestand worden gemaakt en gehost om de instellingen door te geven aan de client.
_autodiscover._tcp.mijndomein.nl. 3600 IN SRV 10 10 443 mijnwebserver.mijndomein.nl
Met dit record wordt er gezorgd dat er naar https://mijnwebserver.mijndomein.nl/autodiscover.xml wordt eggaan en de inhoud uit dit bestand wordt dan gelezen.
Het volgende stuk PHP zorgt voor het genereren van de XML file. Pas de stukken tussen de Server Tags aan naar de eigen mailserver.
autodiscover.php
<?php
//get raw POST data so we can extract the email address
$data = file_get_contents("php://input");
preg_match("/\<EMailAddress\>(.*?)\<\/EMailAddress\>/", $data, $matches);
//set Content-Type
header("Content-Type: application/xml");
?>
<?php echo '<?xml version="1.0" encoding="utf-8" ?>'; ?>
<Autodiscover xmlns="http://schemas.microsoft.com/exchange/autodiscover/responseschema/2006">
<Response xmlns="http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a">
<Account>
<AccountType>email</AccountType>
<Action>settings</Action>
<Protocol>
<Type>POP3</Type>
<Server>mail.rwts.com.au</Server>
<Port>110</Port>
<LoginName><?php echo $matches[1]; ?></LoginName>
<DomainRequired>off</DomainRequired>
<SPA>off</SPA>
<SSL>off</SSL>
<AuthRequired>on</AuthRequired>
<DomainRequired>off</DomainRequired>
</Protocol>
<Protocol>
<Type>IMAP</Type>
<Server>mail.rwts.com.au</Server>
<Port>993</Port>
<DomainRequired>off</DomainRequired>
<LoginName><?php echo $matches[1]; ?></LoginName>
<SPA>off</SPA>
<SSL>on</SSL>
<AuthRequired>on</AuthRequired>
</Protocol>
<Protocol>
<Type>SMTP</Type>
<Server>mx1.rwts.com.au</Server>
<Port>25</Port>
<DomainRequired>off</DomainRequired>
<LoginName><?php echo $matches[1]; ?></LoginName>
<SPA>off</SPA>
<SSL>off</SSL>
<AuthRequired>on</AuthRequired>
<UsePOPAuth>on</UsePOPAuth>
<SMTPLast>on</SMTPLast>
</Protocol>
</Account>
</Response>
</Autodiscover>
Maak vervolgens nog wel een .htaccess aan zodat autodiscover.php naar autodiscover.xml wordt omgezet.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ autodiscover.php [NC,L]