Mail app in Nextcloud not working with NS8 mail server

Hi all,

I tried to use the nextcloud Mail app today to receive mails on an NS8 instance. However, I do not get it to work.
I am using current NS8 server based on Debian, freshly installed yesterday, hosting both the Mail and Nextcloud apps. In nextcloud, I installed the Mail app, and tried to configure the ns8 as Mail server. However, I always get “IMAP Server cannot be reached” within nextcloud, and the mail account cannot be created.
As IMAP Server, I tried both the host name of the ns8 server, the IP, and 127.0.0.1, but nothing works.

Any advice how to proceed?

Thank you.

You could try 10.5.4.1 (default wireguard ip of node1)

Thank you. Unfortunately, that also fails.

It seems like nextcloud is unable to reach the mailserver. I don’t know why…

1 Like

Maybe related, I’ll check later…

EDIT:

No, this is already implemented.

1 Like

Maybe you need to use the mail hostname, it’s shown on the status page:

Without valid cert it worked with following settings when mail is on the same node as nextcloud.

1 Like

Thank you. I tried it with the same settings related to my setup, and it is not working with “IMAP server cannot be reached”.
When I enter the nextcloud container with

runagent -m nextcloud1 podman exec -it nextcloud-app /bin/sh

I can ping the mail host, and it resolves to 127.0.1.1
There is no telneg installed in the container, so I cannot try to connect to port 143 unfortunately.

I have Debian instead of rocky. Could that have an impact?

When I ping the mail hostname, I get the LAN IP of the host instead of 127.0.1.1…

/var/www/html # ping mail.ns8rockytest.com
PING mail.ns8rockytest.com (192.168.3.144): 56 data bytes
64 bytes from 192.168.3.144: seq=0 ttl=42 time=0.198 ms

Did you try to use the mail hostname? To get it via CLI:

runagent -m mail1 grep MAIL_HOSTNAME environment

Install busybox-extras, needed for telnet, see also How to install telnet into a alpine docker container. This is useful when using the celery remote debugger in a dev environment. · GitHub

apk add busybox-extras

Run telnet using busybox-extras:

/var/www/html # busybox-extras telnet mail.ns8rockytest.com 143
Connected to mail.ns8rockytest.com
* OK [CAPABILITY IMAP4rev1 SASL-IR LOGIN-REFERRALS ID ENABLE IDLE LITERAL+ STARTTLS AUTH=PLAIN AUTH=LOGIN] Dovecot ready.

These changes are lost when the container is restarted.

I don’t think so but needs to be tested to be sure…

Thank you very much for your help.

I have the following findings now:

Initially, I have left the mailserver hostname unconfigured, so it defaults to the NS8 hostname. The nextcloud container resolves this name to 127.0.1.1, and port 143 cannot be reached from within nextcloud (tried with telnet, thanks for the hint how to install it).

As step 2, I tried to telnet into the server IP:143 from the nextcloud container, which works. However, when entering the IP address in the nextcloud mail app, it still fails to connect (reason unclear to me).

As a third step, I tried to configure a seperate mail hostname: I setup a specific DNS A and PTR record for the mail service, and configured the mail hostname in NS8 Mail app under settings / general. Now, I entered that hostname into the nextcloud app, which works as described by @mrmarkuz

Thank you again for the help, problem solved. However, I do not understand why entering the IP as mailserver fails in the nextcloud app, while entering a hostname that points to exactly the same IP works…

1 Like

Nextcloud doesn’t allow local hostnames or IPs as remote servers by default, see also mail/doc/admin.md at main · nextcloud/mail · GitHub

Easiest way is to allow it using occ, see also GitHub - NethServer/ns8-nextcloud: Nextcloud module for NS8 :

runagent -m nextcloud1 occ config:system:set --value true allow_local_remote_servers

Now IPs should work as imap host in Nextcloud mail app.

1 Like