Autodiscover mail settings outlook

Hello,

I’m fully exploring this wonderfull piece of software, but facing some problems.

As i’m creating a top level domain, username seems to be the first part before the .tld, so i created the virtual server ‘liena.be’ and username is liena.

So far so good. Set up thunderbird for liena@liena.be, autodiscover works like a charm. But! When i want to add this mail into the Outlook application, the autodiscover won’t work (and it’s needed as username is liena instead of liena@liena.be and i can’t change username during manual setup in outlook).

When i look into the apache access logs i see this rule for thunderbird:

178.117.26.202 - - [15/Dec/2020:12:53:09 +0100] “GET /autodiscover/autodiscover.xml?emailaddress=liena@liena.be HTTP/1.1” 200 578 “-” “Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36”

correct autodiscover link, it works in browser too.

But for outlook i find this:

52.125.138.0 - - [15/Dec/2020:12:59:08 +0100] “GET /autodiscover/autodiscover.json?Email=liena@liena.be&Protocol=ActiveSync&RedirectCount=1 HTTP/1.1” 404 3627 “-” “OutlookMobileCloudService-Autodetect/1.0.0”

and i can’t access this link on my server, so it’s normal it won’t work.

What am i doing wrong here? I really want that autodiscover thing get to work on outlook too.

Regards,
Frederick

Operating system: Client: Windows 10, Server: Ubuntu 20.04, latest virtualmin package

Hi,

Thanks for the heads up.

To summarize, auto-discover doesn’t work with Outlook because of what – because Outlook searches only for .json link and not .xml? Is this what you see on Apache logs – only .json link and nothing else?

If so, try applying this patch, and restarting Webmin.

It can be done with the following commands:

curl https://raw.githubusercontent.com/virtualmin/virtualmin-gpl/master/feature-mail.pl -o /usr/share/webmin/virtual-server/feature-mail.pl
/etc/webmin/restart

… and then disabling and re-enabling the feature on Email Settings > Mail Client Configuration page.

Please come back and let us know if that fixes your problem.

Hello,

Thanks for the quick answer, was only able to test now. Unfortunatly it doesn’t change.

The problem indeed is, that for outlook, it just searches the .json file, not the .xml, while for thunderbird(mozilla) it only searches the .xml file, and not the .json file.

This is my outlook auto discover script as stated in server templates -> Default settings -> mail client auto configuration:

<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>
    <TTL>24</TTL>
<Server>$IMAP_HOST</Server>
    <Port>$IMAP_PORT</Port>
<LoginName>$SMTP_LOGIN</LoginName>
    <DomainRequired>off</DomainRequired>
    <SSL>$IMAP_SSL</SSL>
<AuthRequired>on</AuthRequired>
  </Protocol>
  <Protocol>
<Type>SMTP</Type>
    <TTL>24</TTL>
<Server>$SMTP_HOST</Server>
    <Port>$SMTP_PORT</Port>
<LoginName>$SMTP_LOGIN</LoginName>
    <DomainRequired>off</DomainRequired>
    <SSL>$SMTP_SSL</SSL>
<AuthRequired>on</AuthRequired>
  </Protocol>
</Account>
</Response>
</Autodiscover>

I also did a test with a new user on the domain: info@liena.be. It seems for that user, the username is user@domain.tld. If i add that in outlook, autodiscover still doesn’t work, but i’m able to add the mailbox as the username is in the form of ‘user@domain.tld’ and not just ‘user’, like the main account is.

I did some further research on the problem… for first i saw this thread:

https://github.com/gronke/email-autodiscover/issues/4

From there i took a look to this link:

https://github.com/mailcow/mailcow-dockerized/blob/master/data/web/autodiscover-json.php

This seems like a small script to check which autodiscover method is used, or autodiscoverV1/2, or activesync, and force autodiscoverV1/2 if mailagent uses activesync (eg. outlook 2016+)

After looking deeper into the patch you purposed, i see the redirect from .json to .xml is implemented, so far so good.

But still, after resetting all services needed, the redirect doesn’t work as i can see in apache access logs:

52.125.140.0 - - [16/Dec/2020:10:53:09 +0100] “GET /autodiscover/autodiscover.json?Email=info@liena.be&Protocol=ActiveSync&RedirectCount=1 HTTP/1.1” 200 3435 “-” “OutlookMobileCloudService-Autodetect/1.0.0”
178.117.26.202 - - [16/Dec/2020:10:53:57 +0100] “GET /autodiscover/autodiscover.xml?emailaddress=liena@liena.be HTTP/1.1” 200 4259 “-” “Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36”

Thanks for the quick answer, was only able to test now. Unfortunatly it doesn’t change.

That was not expected to work, yet it would be interesting to see on the new error messages returned? If you applied the patch, was there something new on Apache logs (access or error) and/or Outlook?

I did some further research on the problem… for first i saw this thread:

Yes, thanks for the further research. I was looking at the exactly the same sources just half an hour ago.

Ideally, we would need an exact specification for Microsoft Outlook on that issue, and what should be on .json output to fit its expectations. From that GitHub page, I can see $autodiscover_config['activesync']['url'] passed as a param, while what it is, is unclear …

I will take a deeper look into it. This might be time consuming.

@FrederickD - What is your Outlook version?

Microsoft Outlook 2019 MSO (16.0.13426.20270) 32-bits :slight_smile:

Yes, something changes in the logs, still searching for .json, but the 404 turned to 200:

52.125.138.0 - - [15/Dec/2020:12:59:08 +0100] “GET /autodiscover/autodiscover.json?Email=liena@liena.be&Protocol=ActiveSync&RedirectCount=1 HTTP/1.1” 404 3627 “-” “OutlookMobileCloudService-Autodetect/1.0.0”
52.125.140.0 - - [16/Dec/2020:08:49:48 +0100] “GET /autodiscover/autodiscover.json?Email=liena@liena.be&Protocol=ActiveSync&RedirectCount=1 HTTP/1.1” 200 3435 “-” “OutlookMobileCloudService-Autodetect/1.0.0”
52.125.140.0 - - [16/Dec/2020:08:52:05 +0100] “GET /autodiscover/autodiscover.json?Email=liena@liena.be&Protocol=ActiveSync&RedirectCount=1 HTTP/1.1” 200 3435 “-” “OutlookMobileCloudService-Autodetect/1.0.0”
52.125.140.0 - - [16/Dec/2020:09:03:23 +0100] “GET /autodiscover/autodiscover.json?Email=liena@liena.be&Protocol=ActiveSync&RedirectCount=1 HTTP/1.1” 200 3435 “-” “OutlookMobileCloudService-Autodetect/1.0.0”
52.125.138.0 - - [16/Dec/2020:09:40:09 +0100] “GET /autodiscover/autodiscover.json?Email=info@liena.be&Protocol=ActiveSync&RedirectCount=1 HTTP/1.1” 200 3435 “-” “OutlookMobileCloudService-Autodetect/1.0.0”
52.125.140.0 - - [16/Dec/2020:10:53:09 +0100] “GET /autodiscover/autodiscover.json?Email=info@liena.be&Protocol=ActiveSync&RedirectCount=1 HTTP/1.1” 200 3435 “-” “OutlookMobileCloudService-Autodetect/1.0.0”

Checked the link in browser, and now i can see: Missing emailaddress parameter

Yesterday it gave a 404 error.

AHA!!

If i test this link:

https://liena.be/autodiscover/autodiscover.json?emailaddress=liena@liena.be

i get the XML output!!

Yes, that was the point of the patch. I was curious if Outlook would choke on the fake .json or not.

Saying that, I assume it doesn’t work still? Has anything changed? Are there errors on Outlook somewhere?

I had a license for Microsoft Office 2019. I am downloading it now to install on my MacBook, to see what’s going on.

Darn it, my Office 2019 doesn’t include Outlook…

No, not working.

It’s just microsoft doing difficult i think, they let outlook working good on activeshares and stuff, and the rest has to find their solution :frowning:

Outlook just shows that it can’t connect to the mailservers, as outlook assumes username is ‘user@domain.tld’ (same as emailadress) and not only ‘user’.

Since version 2019 it is impossible to change username during setup, so no way you can add the mail account without the autodiscover function.

This is frustrating. What a wrong strategy for the company.

I am still anxious and frustrated about the fact that Google didn’t acquire GitHub but Microsoft did.

But, is there a method to change:

52.125.140.0 - - [16/Dec/2020:10:53:09 +0100] “GET /autodiscover/autodiscover.json?Email=info@liena.be&Protocol=ActiveSync&RedirectCount=1 HTTP/1.1” 200 3435 “-” “OutlookMobileCloudService-Autodetect/1.0.0”

into:

52.125.140.0 - - [16/Dec/2020:10:53:09 +0100] “GET /autodiscover/autodiscover.json?emailaddress=info@liena.be&Protocol=ActiveSync&RedirectCount=1 HTTP/1.1” 200 3435 “-” “OutlookMobileCloudService-Autodetect/1.0.0”

? I mean, outlook searches for …autodiscover.json?Email instead of …autodiscover.json?emailaddress

I assume that Outlook should at first parse valid JSON returned from autodiscover, however I wouldn’t be surprised with anything …

You can go to ~/cgi-bin/autoconfig.cgi and change it manually to see what happens?

Thing is, nothing is stated as ‘Email’:

if ($ENV{‘QUERY_STRING’} =~ /emailaddress=([^&]+)/) {
# Thunderbird style
$email = $1;
$email =~ s/%(…)/pack(“c”,hex($1))/ge;
($mailbox, $SMTP_DOMAIN) = split(/@/, $email);
$mailbox && $SMTP_DOMAIN ||
&error_exit(“emailaddress parameter is not in user@domain format”);
}
elsif ($ENV{‘REQUEST_METHOD’} eq ‘POST’) {
# Outlook style
read(STDIN, $buf, $ENV{‘CONTENT_LENGTH’});
$buf =~ /([^@<>]+)@([^<>]+)</EMailAddress>/i ||
&error_exit(“EMailAddress missing from input XML”);
($mailbox, $SMTP_DOMAIN) = ($1, $2);
$email = $1."@".$2;
}
else {
&error_exit(“Missing emailaddress parameter”);
}

Try:

if ($ENV{‘QUERY_STRING’} =~ /Email=([^&]+)/) {

That gave me an XML result in browser, but still not lucky with outlook :frowning:

https://liena.be/autodiscover/autodiscover.json?Email=liena@liena.be

For thunderbird, still able to autodiscover, but no more SSL info, i need to do manually now.

… and before making that change it worked just fine in ThunderBird?

absolutely, like a charm!