SMTP ports explained: 25 vs 465 vs 587 vs 2525
Which SMTP port should you use? A clear guide to ports 25, 465, 587 and 2525, what STARTTLS and implicit TLS mean, and how to fix blocked ports.
Short answer: to send email from an app, device or mail client, use port 587 with STARTTLS or port 465 with implicit TLS. Port 25 is for server-to-server delivery and is blocked on most home and cloud networks. Port 2525 is an unofficial fallback some providers offer when 587 is blocked.
The four ports at a glance
| Port | Purpose | Encryption | Use it when |
|---|---|---|---|
| 25 | Server-to-server relay (MTA to MTA) | Optional STARTTLS | You run a mail server receiving mail. Not for sending from apps. |
| 587 | Message submission | STARTTLS (upgrade) | Default choice for apps and mail clients. |
| 465 | Message submission | Implicit TLS from the first byte | Your library expects TLS on connect, or 587 is blocked. |
| 2525 | Unofficial alternate submission port | STARTTLS | Your network blocks 587 and 465. |
Port 25: for servers, not apps
Port 25 is how mail servers hand messages to each other, and it's where spam from infected machines would flow. That's why residential ISPs (Comcast, AT&T and others), and cloud providers including AWS, Google Cloud and Azure, block or throttle outbound port 25 by default. If your app "can't connect" on 25, that's almost certainly why. Don't fight it: submit mail on 587 or 465 to an authenticated relay.
Port 587 and STARTTLS
Port 587 is the standard submission port (RFC 6409). The client connects in plain text, sends EHLO, then STARTTLS to upgrade the connection to TLS before authenticating. A properly configured client refuses to send credentials if the upgrade fails. More on STARTTLS.
In most libraries:
// Nodemailer, port 587
nodemailer.createTransport({ host: "smtp.stackemails.com", port: 587, secure: false, requireTLS: true, auth: { user: "stackemails", pass: process.env.STACKEMAILS_API_KEY } });
Port 465 and implicit TLS
Port 465 was briefly registered for SMTPS in the 1990s, deprecated, and then officially re-registered for submission over implicit TLS by RFC 8314 in 2018. TLS starts before any SMTP command, like HTTPS. RFC 8314 actually recommends implicit TLS for submission. In most libraries this is secure: true or SMTP_SSL:
# Python, port 465
with smtplib.SMTP_SSL("smtp.stackemails.com", 465) as smtp:
smtp.login("stackemails", api_key)
587 or 465?
Both are secure and widely supported. Pick whichever your library makes easiest:
- Use 465 when the library has a simple "SSL/TLS" toggle, or when you want TLS guaranteed from the first byte.
- Use 587 when the setting is labelled "STARTTLS" or "TLS" (some apps call STARTTLS "TLS" and implicit TLS "SSL").
The classic mistake is mixing them: port 465 with STARTTLS, or port 587 with SSL. The connection hangs or fails with a "wrong version number" error.
Port 2525
Not an official standard, but many email services (including SendGrid, Mailgun and Postmark) listen on 2525 as an alternative submission port for networks that block the others. Treat it as a fallback.
Troubleshooting a blocked port
From the machine that sends mail:
# Test TCP connectivity
nc -vz smtp.stackemails.com 587
# Test the TLS handshake on 465
openssl s_client -connect smtp.stackemails.com:465 -quiet
If the connection times out on every port, the network blocks outbound SMTP. Use an HTTP email API instead: it runs over port 443 like any web request. See our send email guides.
SMTP settings for popular providers
Looking up a specific provider? We keep SMTP settings for 25+ providers, including Gmail, Office 365, Outlook, SendGrid and Amazon SES.
Enjoyed this article?
See more from Stack Emails in Google Search.