Diagnostic step 1
Capture Mail network traffic without exposing credentials: use tcpdump to capture IP/port/connect attempts to the IMAP server while reproducing the failure (sudo tcpdump -i <iface> host <mail-ip> and port 993) and inspect whether connections are attempted and whether TCP handshake succeeds