# What Is STARTTLS (opportunistic TLS upgrade)?

> STARTTLS is a command that upgrades an existing plaintext connection in protocols such as SMTP, IMAP and POP3 to TLS on the same port.

Source: https://ssl.sh/glossary/starttls/
Last updated: 2026-11-10

STARTTLS (called STLS in POP3) lets a client connect in plaintext, check that the server advertises TLS support, and then issue a command that switches the same TCP connection to TLS. For SMTP it is defined in [RFC 3207](https://www.rfc-editor.org/rfc/rfc3207); IMAP and POP3 use RFC 2595, and XMPP and LDAP have their own equivalents. The alternative is implicit TLS, where TLS starts immediately on a dedicated port such as 465 for SMTP submission, 993 for IMAP or 995 for POP3.

## Why it matters
The upgrade step itself is unprotected. An active attacker can remove the STARTTLS capability from the server's response or make the command fail, and many clients then continue in plaintext. Between mail servers on port 25, TLS is usually opportunistic and certificates are often not verified at all. Defenses: configure user clients to require TLS, and for server-to-server mail publish [DANE](https://ssl.sh/glossary/dane/) [TLSA](https://ssl.sh/glossary/tlsa/) records (RFC 7672) or an MTA-STS policy (RFC 8461), so that sending servers insist on authenticated TLS. RFC 8314 recommends implicit TLS for users submitting and reading mail.

## Example
```bash
openssl s_client -connect mail.example.com:25  -starttls smtp -servername mail.example.com </dev/null
openssl s_client -connect mail.example.com:587 -starttls smtp -servername mail.example.com </dev/null
openssl s_client -connect mail.example.com:143 -starttls imap -servername mail.example.com </dev/null
```

The [STARTTLS checker](https://ssl.sh/tools/starttls-checker/) runs the same test from outside your network.

## Common misconceptions
- **STARTTLS is a different protocol from TLS.** It is only a command; once issued, the connection runs ordinary TLS with ordinary certificates.
- **If both mail servers support STARTTLS, mail is encrypted end to end.** It protects each hop only, and without DANE or MTA-STS a downgrade on a hop can go unnoticed. End-to-end protection needs S/MIME or similar.
- **Ports 465 and 587 are interchangeable.** Port 465 expects TLS from the first byte; port 587 expects plaintext followed by STARTTLS. Mixing them up causes handshake failures or timeouts.

## Related terms

- [TLS](https://ssl.sh/zh/glossary/tls/): TLS 是 IETF 制定的传输层安全协议，为 HTTPS 等网络连接提供加密、完整性保护和服务器身份认证，是 SSL 的继任者。
- [DANE](https://ssl.sh/zh/glossary/dane/): DANE 是一种利用经 DNSSEC 签名的 TLSA 记录，把 TLS 服务器的证书或公钥与其域名绑定起来的协议。
- [TLSA 记录](https://ssl.sh/zh/glossary/tlsa/): TLSA 记录是一种 DNS 记录，声明某个端口和协议上的 TLS 服务必须出示哪张证书或哪个公钥，供 DANE 校验使用。
- [降级攻击](https://ssl.sh/zh/glossary/downgrade-attack/): 降级攻击是指攻击者迫使客户端和服务器协商出比双方实际支持的更旧的协议版本或更弱的算法，从而利用其中的弱点。
- [SSL 剥离](https://ssl.sh/zh/glossary/ssl-stripping/): SSL 剥离是一种中间人攻击，攻击者截获本应把用户引向 HTTPS 的跳转或链接，让用户一直停留在明文 HTTP 上。
- [S/MIME](https://ssl.sh/zh/glossary/smime/): S/MIME 是一种使用 X.509 证书和 CMS 格式对电子邮件进行端到端签名和加密的标准。
