Test a Mail Server's TLS with openssl s_client

Handshake with SMTP/IMAP servers over STARTTLS or implicit TLS and inspect the certificate chain interactively.

LinuxDiagnosticsopensslemailtlsLow risk
Run openssl s_client -starttls smtp -connect smtp.example.com:587 -brief — a successful handshake prints the protocol, cipher and certificate subject.

01Command

Command
$ openssl s_client -starttls smtp -connect smtp.example.com:587 -brief

02What it does

For submission/port 587 and imap 143, mail servers start in plaintext and upgrade with STARTTLS, which -starttls smtp (or imap/pop3) negotiates before the handshake; for implicit TLS ports like 465 or 993, drop the -starttls flag. -brief condenses the output to the negotiated protocol, cipher and server certificate subject/issuer, while the full output lets you verify expiration with the dates shown in the certificate block. 'Verify return code: 0 (ok)' at the end is the quick pass/fail signal.

03Risk

RiskLow risk
Requirementsopenssl package (preinstalled)
!Warning: s_client shows the certificate but does not enforce policy — a certificate that is merely present may still be expired or self-signed, so read the verify code and dates.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

  • openssl s_client(1) — SSL/TLS client program
    Ubuntu manpages · community · 2026-09-17
    Evidence: Man page documents the -starttls option with the smtp protocol value, -connect host:port, and -brief; confirms 's_client' and 'starttls' appear in the text.
  • openssl-s_client(1ssl) — Debian man page
    Debian manpages · community · 2026-09-17
    Evidence: Man page text includes -starttls with protocol values smtp/pop3/imap and -brief option, confirming the flags used.

Last verified: 2026-09-19 · Category: Security & Privacy

06Related solutions