Autodiscover Information For Mail Clients in DirectAdmin

Autodiscover is a system to figure out which settings to use for the POP/IMAP/SMTP settings, that allows the mail client users to configure their email address automatically. We can set up this in DirectAdmin with basic requirement: subdomain and an SRV record.

You can add the SRV record on which domain you wish to use these settings for. If you have any global SSL certificate in exim/dovecot for your hostname, it will be better to make sure the clients use the correct value. Hence they did not get SSL certificate errors.

Let’s suspect that you are connecting your clients to server.hostname.com with clientdomain.com for both IMAP and SMTP. Then first of all need to create a subdomain called ” autodiscover.hostname.com ” to store the  XML.

1) Need to setup SRV record on the mentioned client domains “clientdomain.com” DNS zone:

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

2) Next, need to create the subdomain autodiscover.hostname.com in Directadmin, then can we add the follwing code into a file called 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”);

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>IMAP</Type>

<Server>server.hostname.com</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>POP3</Type>

<Server>server.hostname.com</Server>

<Port>995</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>server.hostname.com</Server>

<Port>587</Port>

<DomainRequired>off</DomainRequired>

<LoginName><?php echo $matches[1]; ?></LoginName>

<SPA>off</SPA>

<Encryption>TLS</Encryption>

<AuthRequired>on</AuthRequired>

<UsePOPAuth>off</UsePOPAuth>

<SMTPLast>off</SMTPLast>

</Protocol>

</Account>

</Response>

</Autodiscover>

 SRV record always using port 443 for autodiscover.hostname.com, So make sure you have got a valid certificate setup for this subdomain. You can check this by entering the domain on https://www.sslshopper.com/ssl-checker.html or can try to access it on a browser with https://autodiscover.hostname.com

3) Finally, we will need to set up a .htaccess hidden file so that we can trace any request to the needed subdomain like autodiscover.hostname.com results in the autodiscover.php being called. We need to add the following lines to the .htaccess file under the subdomain DocumentRoot.

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} -s [OR]

RewriteCond %{REQUEST_FILENAME} -l [OR]

RewriteCond %{REQUEST_FILENAME} -d

RewriteRule ^.*$ – [NC,L]

RewriteRule ^.*$ autodiscover.php [NC,L]

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

What virtualization software do you use?

We use Parallels Virtuozzo Containers (PVC).

Why is my VPS constantly crashing?

There are several causes to why you may not be able to access your VPS. Some users often mistake...

What kind of support do you offer?

We offer Fully Managed VPS packages. For a list of items that we support, please refer to the...

What kind of software can I install on my VPS?

As you have full root access, you may install any compatible software on your VPS. However, any...

What is Virtuozzo?

Virtuozzo is the VPS technology created by SWsoft which allow us to create isolated VPS servers...