Mail app failure to connect to local mail server

We recently installed Nextcloud hub and we successfully connected to our mail server to be able to send notifications to users. However, Mail app constantly fails to connect and keeps displaying “Unexpected error during account creation”.
Now our mail server is locally hosted with a self-signed certificate. Do we need to install this certificate on our Nextcloud hub? And if yes, can someone please guide me through the steps or even share some links?
Note: I checked nextcloud.log file for any related errors, please find them below
“Creating account failed: Connection to IMAP at failed. No supported IMAP authentication method could be found”
“Creating account failed: Connection to IMAP at failed. Error connecting to mail server.”
“Creating account failed: Connection to IMAP at failed. Could not open secure TLS connection to the IMAP server.”

I think the following thread matches your question perfectly. Next time, just try to use the search function of the foprum first :wink:

Unfortunately none of the suggested solutions worked for me. One link showed how to import a self-signed certificate into the Ubuntu server for Nextcloud to use but still hasn’t worked for me.
These are the steps I followed:

  1. I copied the certificate to /usr/local/share/ca-certificates
  2. I converted the certificate from .cer to .crt
  3. Run the command update-ca-certificates
  4. Checked ssl/certs directory and indeed certificate was imported in PEM form.

I captured traffic and found the following

  1. The reset packets are from both sides.
  2. The Forbidden packet is from the Mail server side.

What am I missing?