WebMail Pro documentation

Configuring autodiscover

It's possible to configure WebMail Pro so that it will send IMAP/SMTP details for the mail server at autodiscover requests sent by clients like Microsoft Outlook.

Please bear in mind that this configuration is performed for primary domain. For example, if you have WebMail Pro installed at webmail.domain.com, autodiscover needs to be configured for domain.com host, and it's assumed that you're dealing with @domain.com email addresses.

If reconfiguring primary domain is not an option, you can set up autodiscover.domain.com - most clients would check both and use whichever one is available.

Actually, to discover settings for email account in domain.com domain, email clients check against URL of the following kind:

domain.com/Autodiscover/Autodiscover.xml

or:

autodiscover.domain.com/Autodiscover/Autodiscover.xml

So if you wish to have autodiscover enabled, reconfigure your web server by adding an alias pointing from URL of that kind to https://webmail.domain.com?autodiscover - with the correct URL of WebMail Pro specified.

NB: For this to work, make sure you have correct IMAP and SMTP server names supplied in data/settings/modules/Mail.config.json file, "ExternalHostNameOfLocalImap" and "ExternalHostNameOfLocalSmtp" respectively.

Apache configuration

RewriteEngine on
RewriteRule "^autodiscover/autodiscover.xml$" "/?autodiscover" [NC,L]

Nginx configuration

location ~ /(?:a|A)utodiscover/(?:a|A)utodiscover.xml {
    return 307  https://webmail.domain.com/?autodiscover;
}

Testing autodiscover

To make sure everything works correctly, place the following PHP script into your web directory, adjust autodiscover URL and supply an email address:

<?php
$sUrl = "https://domain.com/autodiscover/autodiscover.xml";
$sEmail = "user@domain.com";
$sPost = '<Autodiscover xmlns="http://schemas.microsoft.com/exchange/autodiscover/outlook/requestschema/2006"><Request><EMailAddress>'.$sEmail.'</EMailAddress><AcceptableResponseSchema>http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a</AcceptableResponseSchema></Request></Autodiscover>';
$rCurl = curl_init();
$acurlOpt = array(
    CURLOPT_URL => $sUrl,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => $sPost,
    CURLOPT_SSL_VERIFYPEER => false,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_HTTPHEADER => array('Content-Type: text/xml')
);
curl_setopt_array($rCurl, $acurlOpt);
$mResult = curl_exec($rCurl);
curl_close($rCurl);
echo "<pre>".htmlspecialchars($mResult)."</pre>";

Open the script in web browser, you should see a bunch of settings for the account you have specified:

<?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">
        <Culture>en:us</Culture>
        <User>
            <DisplayName>user@domain.com</DisplayName>
            <EMailAddress>user@domain.com</EMailAddress>
        </User>
        <Account>
            <AccountType>email</AccountType>
            <Action>settings</Action>
            <Protocol>
                <Type>IMAP</Type>
                <Server>domain.com</Server>
                <LoginName>user@domain.com</LoginName>
                <Port>143</Port>
                <SSL>off</SSL>
                <SPA>off</SPA>
                <AuthRequired>on</AuthRequired>
            </Protocol>
            <Protocol>
                <Type>SMTP</Type>
                <Server>domain.com</Server>
                <LoginName>user@domain.com</LoginName>
                <Port>25</Port>
                <SSL>off</SSL>
                <SPA>off</SPA>
                <AuthRequired>on</AuthRequired>
            </Protocol>
        </Account>
    </Response>
</Autodiscover>