Mail servers have certificates too, and since you never see them in a browser, they're the ones that expire unnoticed. When it happens, mail apps start showing errors and some servers stop delivering to you.
Ports with direct TLS
IMAPS (993), POP3S (995) and SMTPS (465) start with TLS, so it's the same command as for a website:
echo | openssl s_client -connect mail.example.com:993 -servername mail.example.com 2>/dev/null \
| openssl x509 -noout -subject -issuer -enddate
Ports with STARTTLS
Submission (587), server-to-server SMTP (25) and IMAP (143) start unencrypted and switch to TLS, so openssl needs to know the protocol:
# submission
echo | openssl s_client -connect mail.example.com:587 -starttls smtp 2>/dev/null | openssl x509 -noout -enddate
# IMAP
echo | openssl s_client -connect mail.example.com:143 -starttls imap 2>/dev/null | openssl x509 -noout -enddate
Home and office networks often block port 25. Run that one from a server.
Common problems
The most common one: the certificate was renewed, but Postfix or Dovecot still serves the old one. They only read the file at start, so reload them after every renewal.
Next is a name mismatch. The certificate covers example.com, but mail apps connect to mail.example.com.
Put every name people actually use on the certificate.
And a missing intermediate certificate. Some clients don't mind, others refuse. Point the server at the full chain
(fullchain.pem with Let's Encrypt).
Checking it from outside
The bulk check takes ports, e.g. mail.example.com:993.
CertNudge can watch the same addresses, but STARTTLS ports aren't supported yet.