SMTP relay
SMTP ports 587, 465 and 2525: which one to use
By mailers.io team Published 5 min read
public/media/blog-smtp-ports-587-465-2525-cover.webp Three numbers come up whenever someone sets up SMTP from an application: 587, 465 and 2525. They all do roughly the same job, which is to let your app hand a message to a mail server so that the server delivers it. The differences are in how the connection is encrypted and in which networks let it through. This post explains the three and says which one to reach for.
Submission is not delivery
SMTP is used in two different places. Between mail servers, a server that has your message connects to the recipient’s server and delivers it, usually on port 25. That is delivery. Between your app and your own mail server or provider, the app connects, signs in and gives the message over. That is submission, and it has its own ports.
Keeping them apart matters for two reasons. Submission needs authentication, because otherwise anyone could use the server to send. And many hosting companies block outbound port 25 from ordinary servers to limit spam, so an app that tries to deliver directly often cannot. Submitting to a relay on 587, 465 or 2525 avoids both problems: you sign in, and the relay does the delivery.
How the encryption starts
There are two ways to protect an SMTP connection with TLS.
- STARTTLS. The client connects in plain text, asks the server whether it supports STARTTLS, and then upgrades the same connection to TLS. Nothing sensitive, such as a password, is sent before the upgrade. Ports 587 and 2525 work this way.
- Implicit TLS. The connection is wrapped in TLS before any SMTP words are spoken, the same way HTTPS works. Port 465 works this way. It was briefly deprecated, then reinstated as the port for implicit-TLS submission, and it is in wide use today.
The settings in a library or app usually call these “STARTTLS” and “SSL/TLS”. If you choose the wrong mode for the port, you will see a hang or a handshake error, not a clear message. A client that expects TLS at the start will wait forever on a server that is waiting for the client to speak, and the reverse is also true.
The three ports on the mailers.io relay
The SMTP relay accepts mail on all three ports.
| Port | TLS mode | Sign-in |
|---|---|---|
| 587 | STARTTLS | PLAIN or LOGIN, only after TLS |
| 465 | Implicit TLS | PLAIN or LOGIN, only after TLS |
| 2525 | STARTTLS | PLAIN or LOGIN, only after TLS |
The relay does not offer sign-in on a connection that is not yet encrypted. If a client tries to authenticate before it has upgraded, the server refuses. That is a protection for your credentials, and it is also why a mis-set “no encryption” option in an app fails loudly instead of leaking a password.
The host name to connect to is shown in your account when you create an SMTP key. Use that host for all three ports.
Which one should you choose
Start with 587. It is the standard submission port, every mail library supports it, and most networks allow it. Set the security mode to STARTTLS, not “none” and not “SSL”.
Use 465 when the client insists on implicit TLS. Some older applications and a few devices only know how to open a TLS connection from the first byte. Others simply default to it. If your tool has a single “use SSL” checkbox, 465 is usually what it wants.
Use 2525 when 587 is blocked. Some corporate networks, hotels and cloud hosts filter 587, often as a side effect of a blanket rule about mail. 2525 is not an official port, but it behaves exactly like 587 and gets past most of those filters. It is a fallback, not a first choice.
Do not use port 25 for submitting from an app. Even when it is open, it is the port that receives the most scanning and the strictest filtering, and the relay is not the place for it.
A quick way to test a port
Before blaming your app, check that the port is reachable and that TLS starts. Many tools can do this; the OpenSSL client is a common one.
Replace <smtp-host> with the SMTP host shown with your SMTP credentials in the app. The first line below tests STARTTLS on 587 or 2525, and the second tests implicit TLS on 465.
openssl s_client -starttls smtp -connect <smtp-host>:587
openssl s_client -connect <smtp-host>:465
A working connection prints the server certificate and a greeting. If the connection times out, the port is probably blocked between you and the server, and the answer is to try another one. If it connects but the handshake fails, the mode does not match the port.
What happens after sign-in
The sign-in uses an SMTP key that you create in the app. Details about the key, its limits and how to revoke it are in SMTP relay credentials and limits.
After the message is accepted, the relay does not send it from one fixed machine. It goes through your own sending servers, using your rotation. If one of your servers fails, the next one in the rotation is tried, up to three attempts, which is the default routing rule on every plan. The same idea is explained in why one provider is a single point of failure. Suppressed recipients are skipped and cost nothing, and each recipient that is sent uses one credit.
That is the point of the relay. Your app talks to a single stable address and port. Which provider carries the message is a decision made behind it.
Common mistakes
- Wrong TLS mode for the port. STARTTLS on 465 or implicit TLS on 587 will hang or fail the handshake.
- Trying to sign in before TLS. The server refuses it by design. Make sure the library is set to upgrade, or to connect with TLS.
- Assuming port 25 will work from a cloud host. It often will not, and it is not the right port even where it does.
- Using your login password. The relay uses an SMTP key, not your account password.
- Choosing 2525 because it is unusual. It is only worth using when 587 does not connect.
Where to go next
If you are deciding between the relay and HTTP, read SMTP relay or API: choosing how your app sends. For the limits that apply once you are connected, see the next post in this series on credentials and limits. The transactional e-mail page shows how app mail fits with the rest of the platform.
Questions and answers
Which port should I try first?
587 with STARTTLS. It is the standard port for an app that submits mail, and nearly every SMTP library supports it.
Is 2525 an official port?
No. It is an informal alternative that many providers offer for networks that block 587. It behaves like 587: STARTTLS, then sign-in.
Can I use port 25?
Not for submitting from an app. Port 25 is for servers handing mail to each other, and many hosting networks block outbound connections on it.
Written by the mailers.io team. Published .