The three SMTP ports are not three flavours of the same thing. Two of them (587 and 465) are submission ports: an authenticated user or application handing a new message to its own provider. The third (25) is relay: one mail server delivering to another server on the public internet. Choosing the wrong one is behind a large share of "my app cannot send email" tickets.
What is each SMTP port actually for?
Port 25 — MTA-to-MTA relay
Port 25 is the original SMTP port and the only one that matters for inbound mail. When Gmail delivers a message to your domain, it looks up your MX records, picks the lowest-priority host, and connects to it on TCP 25. There is no authentication in that transaction — the sending server is anonymous, and the receiving server decides whether to accept the message based on SPF, DKIM, DMARC, reputation, and its own filtering.
Because port 25 is anonymous by design, it is also the port compromised machines use to spew spam. Almost every residential ISP and most cloud providers block outbound TCP 25 by default, and many will only unblock it after a support request. That block does not affect your ability to *receive* mail on 25 — it affects your ability to originate connections on it. If you are unsure which direction is failing, read Is Port 25 Blocked? and test both directions.
Port 587 — message submission with STARTTLS
Port 587 is the Message Submission port defined by RFC 6409. A client connects in plaintext, issues EHLO, sees STARTTLS in the capability list, upgrades the connection to TLS, and only then authenticates and sends. The key property is that a well-configured submission server does not advertise AUTH before TLS is established, so credentials never cross the wire in the clear.
You can see that behaviour directly. The plaintext EHLO below advertises STARTTLS but no AUTH line; after the upgrade, AUTH appears.
openssl s_client -starttls smtp -crlf -connect smtp.gmail.com:587
# After the handshake completes, type:
# EHLO test.example.com
# QUITPort 465 — implicit TLS submission
Port 465 has a messy history. It was registered as "smtps" in the 1990s, then de-registered in favour of STARTTLS on 587, which is why a decade of documentation called it deprecated. RFC 8314 (2018) reversed that: 465 is now formally registered as submissions, and the RFC recommends implicit TLS as the preferred submission mechanism over STARTTLS. There is no plaintext phase at all — the TLS handshake starts immediately on connect.
That matters operationally because a STARTTLS negotiation can be stripped by a middlebox: an on-path attacker rewrites the STARTTLS capability out of the EHLO response and the client silently falls back to plaintext unless it is configured to require TLS. Implicit TLS has no such downgrade surface. If your client library lets you choose, 465 is the slightly safer default.
openssl s_client -connect smtp.gmail.com:465 -crlf -quiet
# 220 smtp.gmail.com ESMTP ... gsmtp
# EHLO test.example.com
# 250-smtp.gmail.com at your service
# 250-AUTH LOGIN PLAIN XOAUTH2 ...Port 2525 — the unofficial escape hatch
Port 2525 has no IANA assignment for SMTP and no RFC behind it. It exists because hosted SMTP relay providers needed a port that residential ISPs and cloud firewalls do not filter, and 2525 was conveniently unused. Providers that offer it typically run the same STARTTLS submission service there as on 587. Treat it as a fallback when 587 and 465 are both blocked by a network you do not control, and confirm in your provider's current documentation that they actually listen on it.
Which SMTP port should I use? A comparison
| Port | Registered name | Role | TLS model | Auth | Who connects |
|---|---|---|---|---|---|
| 25 | smtp | MTA-to-MTA relay and inbound delivery | Opportunistic STARTTLS | None (anonymous) | Other mail servers |
| 587 | submission | Message submission (RFC 6409) | STARTTLS upgrade | Required | Mail clients, apps, scripts |
| 465 | submissions | Message submission (RFC 8314) | Implicit TLS on connect | Required | Mail clients, apps, scripts |
| 2525 | Not assigned for SMTP | Alternate submission port | Usually STARTTLS | Required | Apps behind restrictive firewalls |
How do I configure a client or application correctly?
The single most common misconfiguration is mismatching the port and the encryption mode. Libraries and mail clients usually expose these as separate settings, and pairing them wrongly produces confusing errors rather than a clean failure.
- Port 587 + STARTTLS. In most libraries this is the
starttls/TLS/ "explicit TLS" option. Setting an SMTP library to "SSL/implicit TLS" on 587 makes the client send a TLS ClientHello to a server expecting plaintext — you get a handshake timeout or a garbled-response error. - Port 465 + implicit TLS. Called
SSL,SMTPS, or "SSL/TLS" in most UIs. Setting STARTTLS on 465 makes the client wait for a plaintext220banner that never comes in the clear, so it hangs until timeout. - Require TLS, do not merely prefer it. On 587, set the library flag that aborts if STARTTLS is unavailable. Silent plaintext fallback is the whole reason RFC 8314 prefers implicit TLS.
- Verify the certificate. Disabling certificate validation to "make it work" is how a stripped-TLS problem gets papered over. Check the submission host's certificate with the SSL Certificate Checker instead.
- Never point an application at port 25 on your own MX host. Your inbound MX will refuse to relay for you unless it is badly misconfigured as an open relay.
How do I tell whether the port or the credentials are the problem?
Split the question in two. First establish whether TCP reaches the host at all, then whether SMTP behaves as expected on that port. A connection that hangs with no banner is almost always a firewall drop; a connection that is refused immediately is usually nothing listening; a banner followed by an auth failure is a credentials or policy problem, not a network one.
# Which hosts receive mail for the domain?
dig +short MX example.com
# Does anything answer on the submission ports?
openssl s_client -starttls smtp -crlf -connect mail.example.com:587 </dev/null
openssl s_client -crlf -connect mail.example.com:465 </dev/nullRun the same probes from our servers with the Port Checker to find out whether the block is on your side or theirs. If the port is open from us but closed from your host, the filter is local — your ISP, your cloud provider's security group, or a host firewall.
What about TLS policy on port 25?
Encryption on port 25 is opportunistic: the sending server uses STARTTLS if the receiver offers it, and falls back to plaintext if not. MTA-STS and DANE exist to close that downgrade gap for inbound mail, by publishing a policy that says "always use TLS to my MX hosts, with a valid certificate". If you run your own inbound mail, check what you are publishing with the MTA-STS & TLS-RPT Checker. None of this applies to 465 or 587, where TLS is mandatory anyway.
Finally, remember that the port only governs transport. It has nothing to do with whether the receiving side accepts your message. Authentication results are decided by your SPF, DKIM, and DMARC records plus your sending IP's PTR record — run the Email Deliverability Test once the connection itself works.