The Mail app should verify that the servers it connects to are listed in the certificate’s CN. Otherwise the connection should be aborted.
Originally reported at https://github.com/nextcloud/mail/issues/308
The app could be forced into connecting to an insecure server.