Problem with IMAP connection to local MailCow server

Hello group.

I have NextCloud server running everything is working fine except the IMAP configuration of the mail client. When trying to log in to my local MailCow mail server I get an error: IMAP server is unreachable. When I try to configure another mail account located outside my LAN the configuration works fine. From the NC CLI console, PING to the address of my local mail server by both local IP and external URL works correctly.
The DNS query is executed by Windows Server 2022, and the URL redirection to the local IP address is set there.

The NC server is behind the ZORAXY reverse proxy, but this should not affect IMAP communication.

It looks like the NC server could not correctly resolve the DNS query coming from Windows Server 2022. Previously, Exchange Server 2019 was at the mail address and local IP address and the connection worked fine. Now only after changing to MailCow I cannot connect to it from NC.

The Basics

  • Nextcloud Server version:
    • 31.0.6
  • Operating system and version:
    • Ubuntu 24.04
  • Reverse proxy and version:
    • ZORAXY

Multiple possibilities. Some hints and logging suggestions in here: imap server not reachable · Issue #7872 · nextcloud/mail · GitHub

Please check and show:

nslookup your.mailserver ip-of-win2022-server

and

nslookup your.mailserver

I managed to solve the problem.

Finally, I used the following entry:

'allow_local_remote_servers' => true,
'app.mail.imap.timeout' => 20,
'app.mail.smtp.timeout' => 20,
'app.mail.sieve.timeout' => 20,
'app.mail.verify-tls-peer' => false,

in the config.php file.

I’m not sure if disabling TLS verification is safe.

External IMAP providers worked without these variables in config.php, only the local server required them.

Otherwise, the NC mail client refuses to connect to my local MailCow mail server.

You might need to make some global changes to immediately connect to IMAP servers using local and proxy-redirected addresses.

I’m not sure if disabling TLS verification is safe.

No it’s not.If you deactivate the TLS check, you should be aware that this makes the connection fundamentally more vulnerable - even in the local network, this can pose a risk. This is sometimes fine for test purposes, but it is not recommended on a permanent basis.

You might consider creating a cert with mcert
and google howto harden your mailserver with it, or any other ways to trust a local cert but,

My personal recommendation:
Avoid permanently deactivating the TLS check at all costs!

However
good luck!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.