Use port 587 (STARTTLS) or port 465 (implicit TLS) when an app, script or mail client sends email through a provider. Port 25 is for mail servers talking to each other, and most networks block it for everything else. Port 2525 is a non-standard fallback. SMTP always runs over TCP.
SMTP port list at a glance
| Port | Purpose | Encryption | Authentication | Use it for |
|---|---|---|---|---|
| 25 | Server-to-server relay (RFC 5321) | Optional STARTTLS | Usually none | Mail servers delivering to other mail servers |
| 465 | Message submission over implicit TLS (RFC 8314) | TLS from the first byte | Required | Apps and clients, when supported |
| 587 | Message submission (RFC 6409) | STARTTLS upgrade (RFC 3207) | Required | Apps and clients, the safest default |
| 2525 | Unofficial alternative | Usually STARTTLS | Required | Networks that block 587 and 465 |
All four are TCP ports. There is no UDP version of SMTP, because a mail transaction needs a reliable, ordered stream.
Port 587: the standard submission port
Port 587 is the port RFC 6409 set aside for “message submission”: a client handing a new message to its own provider. The connection opens in plain text, the client sends EHLO, the server advertises STARTTLS, and the client upgrades the connection to TLS before it sends a username, password or message.
That upgrade step is the one weakness. If a client is configured to continue without TLS when the server does not offer it, an attacker on the network can strip the STARTTLS line and read the password. Configure your library to require TLS on 587, not just try it.
In most libraries this means “secure: false” plus a “require TLS” flag. In Nodemailer that is secure: false, requireTLS: true. In Python’s smtplib it is calling starttls() before login().
Port 465: implicit TLS
Port 465 starts TLS immediately, before any SMTP command, the same way HTTPS works on port 443. There is no plain-text phase, so there is nothing to strip.
Port 465 has a messy history. It was briefly registered for SMTPS in the 1990s, then reassigned, and many guides still call it “deprecated.” RFC 8314 settled the question in 2018: it registers 465 for submission over implicit TLS and recommends that clients prefer it to STARTTLS.
In code, set the “secure” or “SSL” flag to true on 465 and false on 587. Mixing these up is the most common cause of a connection that hangs and then times out.
Port 25: relay between mail servers
Port 25 is the original SMTP port and is still how mail servers deliver to each other. When Gmail delivers your message to a company that runs Microsoft 365, it connects to that company’s MX host on port 25.
You should not use port 25 to submit mail from an app. Two reasons:
- It is usually blocked. Google Cloud blocks outbound connections on port 25, Azure restricts it for most subscription types, AWS limits it on EC2 by default, and most home ISPs block it too. The blocks exist because infected machines used port 25 to spray spam directly at mail servers.
- Receiving servers distrust it from unknown IPs. Even when the port is open, a message from a cloud VM or home IP sent straight to Gmail is likely to be rejected or filtered. Mail needs to come from a server with a good reputation, a matching PTR record and SPF and DKIM for the domain.
There are narrow exceptions. Some relays that authenticate by IP address, such as Google Workspace’s SMTP relay and Microsoft 365 connectors, accept port 25 from known office IPs. See the Google Workspace relay guide for that setup.
Port 2525: the unofficial fallback
Port 2525 is not registered with IANA for SMTP. Some email services listen on it because certain hosting networks block 25, 465 and 587 together. It behaves like 587: plain text first, then STARTTLS.
Only use it if your provider documents it and you have confirmed the standard ports are blocked. It is not faster or more reliable, just less likely to be filtered.
How to tell which port is blocked
From the machine that will send, test each port with a TCP connection. On macOS or Linux:
nc -vz smtp.example.com 587
nc -vz smtp.example.com 465
To see the server’s greeting and confirm TLS works on 465:
openssl s_client -connect smtp.example.com:465 -crlf -quiet
And to test the STARTTLS upgrade on 587:
openssl s_client -connect smtp.example.com:587 -starttls smtp -crlf -quiet
A timeout means something between you and the server is dropping the connection, usually a firewall or the host’s outbound rules. A “connection refused” means the server is not listening on that port.
Which port should you choose?
| Situation | Port |
|---|---|
| App, script, framework or CMS sending through a provider | 587 or 465 |
| Your library supports implicit TLS well | 465 |
| Older client, or unsure | 587 with TLS required |
| Both 587 and 465 are blocked by the network | 2525, if the provider offers it |
| Running your own MTA that delivers to MX hosts | 25 |
| Printer or scanner that cannot do TLS | 25 to an IP-authenticated relay |
For devices with weaker options, see printer and scanner SMTP settings.
Ports for Mailcandor’s SMTP relay
The Mailcandor SMTP relay listens on smtp.mailcandor.com port 465 (TLS) and port 587 (STARTTLS). The username is mailcandor and the password is an API key. A sending-only key locked to one domain is a good choice for SMTP, because it cannot be used to read data or send from other domains if it leaks.
Host: smtp.mailcandor.com
Port: 465 (TLS) or 587 (STARTTLS)
Username: mailcandor
Password: your API key (mc_live_...)
If you control the code, the HTTPS API avoids port problems entirely, since it runs on 443 like any other web request. The SMTP vs API guide compares the two.