The command for each port
Enter the mail server's host name, not the domain. The MX record tells you which server accepts mail for a domain: dig +short MX example.com or nslookup -type=MX example.com.
Only inserted into the commands in your browser.
Port 25 (inbound, MX) · openssl · Linux, macOS
openssl connects, sends STARTTLS and performs the TLS handshake. The filter shows the certificate (0 s:), the TLS version and the verification result. "Verify return code: 0 (ok)" means the chain is valid.
openssl s_client -connect mail.example.com:25 -starttls smtp -servername mail.example.com </dev/null 2>/dev/null | grep -E "Protocol|Cipher is|Verif|^ 0 s:" 0 s:CN=mail.example.com
Verification: OK
New, TLSv1.3, Cipher is TLS_AES_256_GCM_SHA384
Protocol: TLSv1.3
Verify return code: 0 (ok)Port 25 (inbound, MX) · curl · Linux, macOS
curl speaks SMTP as well. --ssl-reqd aborts if the server does not offer STARTTLS; no message is sent. Handy where openssl is missing.
curl -sv --ssl-reqd smtp://mail.example.com:25 -o /dev/null 2>&1 | grep -E "SSL connection|subject:|expire date|issuer:"* SSL connection using TLSv1.3 / AEAD-CHACHA20-POLY1305-SHA256 / [blank] / UNDEF
* subject: CN=mail.example.com
* expire date: Dec 30 19:09:07 2026 GMT
* issuer: C=US; O=Example Trust Services; CN=Example CA 1Port 587 (submission) · openssl · Linux, macOS
Port 587 is what mail clients use for sending, also with STARTTLS. It is reachable from networks that block port 25.
openssl s_client -connect mail.example.com:587 -starttls smtp -servername mail.example.com </dev/null 2>/dev/null | grep -E "Protocol|Cipher is|Verif|^ 0 s:" 0 s:CN=mail.example.com
Verification: OK
New, TLSv1.3, Cipher is TLS_AES_256_GCM_SHA384
Protocol: TLSv1.3
Verify return code: 0 (ok)Port 587 (submission) · curl · Linux, macOS
The same check with curl. The "expire date" line gives the certificate's expiry.
curl -sv --ssl-reqd smtp://mail.example.com:587 -o /dev/null 2>&1 | grep -E "SSL connection|subject:|expire date|issuer:"* SSL connection using TLSv1.3 / AEAD-CHACHA20-POLY1305-SHA256 / [blank] / UNDEF
* subject: CN=mail.example.com
* expire date: Dec 30 19:09:07 2026 GMT
* issuer: C=US; O=Example Trust Services; CN=Example CA 1Port 465 (implicit TLS) · openssl · Linux, macOS
On port 465 TLS starts immediately, so there is no -starttls. With -starttls openssl reports "Didn't find STARTTLS in server response" here.
openssl s_client -connect mail.example.com:465 -servername mail.example.com </dev/null 2>/dev/null | grep -E "Protocol|Cipher is|Verif|^ 0 s:" 0 s:CN=mail.example.com
Verification: OK
New, TLSv1.3, Cipher is TLS_AES_256_GCM_SHA384
Protocol: TLSv1.3
Verify return code: 0 (ok)Port 465 (implicit TLS) · curl · Linux, macOS
The smtps:// scheme stands for TLS from the first byte.
curl -sv smtps://mail.example.com:465 -o /dev/null 2>&1 | grep -E "SSL connection|subject:|expire date|issuer:"* SSL connection using TLSv1.3 / AEAD-CHACHA20-POLY1305-SHA256 / [blank] / UNDEF
* subject: CN=mail.example.com
* expire date: Dec 30 19:09:07 2026 GMT
* issuer: C=US; O=Example Trust Services; CN=Example CA 1The "</dev/null" ends the session right after the handshake; otherwise openssl waits for input. Without the grep filter you see the full output including the certificate chain and session details.
Read the certificate and its expiry date
Pipe the output into openssl x509 to inspect the mail server's certificate. -checkend tests whether it expires within the given number of seconds (1209600 seconds are 14 days) and sets an exit code you can use in scripts.
openssl s_client -connect mail.example.com:25 -starttls smtp </dev/null 2>/dev/null | openssl x509 -noout -subject -issuer -enddate -checkend 1209600The answer lists subject, issuer and "notAfter", plus "Certificate will not expire" or "Certificate will expire". The name in the certificate has to match the host name from the MX record, otherwise delivery fails for domains that enforce MTA-STS.
OpenSSL 3 versus LibreSSL (macOS)
macOS ships LibreSSL as /usr/bin/openssl. The commands above run on both, but the output differs, and two of the differences lead to wrong conclusions:
- Certificate names: OpenSSL 3.2 and later prints "s:CN=mail.example.com", older versions such as 1.1.1 and 3.0 "s:CN = mail.example.com" with spaces, LibreSSL "s:/CN=mail.example.com". A filter written for one form misses the other.
- The "New, …" line: LibreSSL prints "New, TLSv1/SSLv3" even when TLS 1.3 was negotiated. Go by the "Protocol" line.
- Testing old TLS versions: OpenSSL 3 refuses -tls1_1 by itself in its default configuration ("no protocols available") without ever asking the server. That proves nothing about the server. LibreSSL 3.3.6 still negotiates TLS 1.1 and so shows whether the server accepts it.
- Options: -brief (short summary) and -verify_hostname (checks the name) exist only in OpenSSL; LibreSSL answers "unknown option".
- Host name: without -verify_hostname openssl checks the chain only, not whether the certificate matches the name. "Verify return code: 0" therefore does not mean the name is right.
When it fails
The commands above hide error messages and filter the output. For troubleshooting drop both, that is "2>/dev/null" and everything from "| grep" on; only then do the following messages appear. What they tell you:
- No output, then "Operation timed out" after a while: port 25 is blocked, usually outbound by your ISP or office network. Test from a server or use port 587.
- "Didn't find STARTTLS in server response, trying anyway...": the server does not offer STARTTLS, or the port speaks TLS right away (465) or no SMTP at all.
- "wrong version number": you left out -starttls on a STARTTLS port and are speaking TLS to a server that expects plaintext.
- "Verify return code: 21 (unable to verify the first certificate)": the server does not send the intermediate certificate. The mail server needs the full chain configured.
- "Verify return code: 10 (certificate has expired)": the certificate is past its date, often because the mail server was not reloaded after renewal.
- "Verify return code: 18 (self-signed certificate)": self-signed. Most senders still deliver to port 25; with MTA-STS in enforce mode they will not.
- "Protocol: TLSv1" or "TLSv1.1": outdated. Current guidance, including Germany's BSI TR-03108, asks for TLS 1.2 at least.
Checking without a terminal
The quick check based on BSI TR-03108 tests STARTTLS, TLS version and certificate of a domain's mail servers together with DNSSEC, DANE, TLS-RPT, SPF, DKIM and DMARC and reports each criterion as met or not. The SSL checker reads mail server certificates through its port selector. Why mail server certificates expire unnoticed is the subject of a separate guide.