SMTP Ports Explained: 25 vs 465 vs 587 vs 2525
Pranav Patel
Co-founder·9 min read
On this page

What each SMTP port is for, which one to use for sending email from your app, why port 25 is blocked on most clouds, and how to fix connection timeouts on 587 and 465.
Use port 587 with STARTTLS to send email from an application. Use port 465 if your client prefers implicit TLS. Use an alternate port such as 2525 or 2587 only when your network blocks 587. Do not use port 25 for sending from an app: it is for server-to-server delivery, and most cloud providers block it.
That is the short answer. The rest of this guide explains why, and how to fix the timeouts and TLS errors that come with picking the wrong port.
SMTP ports at a glance
Port 25: server to server only
Port 25 is the original SMTP port from 1982 (RFC 821). Today it has one job: mail servers delivering to other mail servers. When Reloop delivers your message to Gmail, it connects to Gmail's MX on port 25.
You should not send from your app on port 25:
- AWS, Google Cloud, Azure, DigitalOcean, Hetzner and most residential ISPs block outbound port 25 by default to stop spam from compromised machines. Some unblock it on request, and many never do.
- Port 25 usually does not require authentication, so providers do not accept submissions there.
- Many networks allow it without TLS, so credentials and content can travel in plain text.
If you are self-hosting and need port 25 for inbound mail, that is fine. The self-hosted email infrastructure guide covers what to open.
Port 587: the default for sending
Port 587 is the message submission port, defined in RFC 6409. It exists so that mail clients and applications can hand mail to a provider with authentication, separate from server-to-server traffic.
The connection starts in plain text, then upgrades with the STARTTLS command before any credentials are sent:
1S: 220 smtp.reloop.sh ESMTP2C: EHLO app.example.com3S: 250-smtp.reloop.sh4S: 250 STARTTLS5C: STARTTLS6S: 220 Ready to start TLS7 ... TLS handshake ...8C: EHLO app.example.com9S: 250 AUTH PLAIN LOGIN10C: AUTH PLAIN ...A correctly configured provider refuses AUTH before STARTTLS, so your password is never sent unencrypted.
Use 587 unless you have a reason not to. Every SMTP library supports it, and almost no network blocks it.
Port 465: implicit TLS
Port 465 has a messy history. It was registered for SMTPS in 1997, revoked a year later, and then brought back for submission over implicit TLS in RFC 8314 in 2018.
With implicit TLS, the TLS handshake happens as soon as the TCP connection opens. There is no plain-text phase and no STARTTLS command. RFC 8314 actually recommends implicit TLS over STARTTLS because it removes the window for downgrade attacks.
465 vs 587
STARTTLS commandsecure: false (Nodemailer), starttls() (Python)secure: true (Nodemailer), SMTP_SSL (Python)Both are secure when configured correctly. The most common mistake is mixing up the setting with the port:
secure: trueon port 587 hangs, because the client waits for a TLS handshake the server never starts.secure: falseon port 465 fails withwrong version numberorECONNRESET, because the server speaks TLS immediately.
Port 2525: the fallback
Port 2525 is not an official SMTP port. Providers listen on it because some hosting companies and corporate firewalls block 587 and 465. It behaves like 587 (STARTTLS).
Some providers use other alternates. Reloop accepts submissions on 587, 2587 and 2025, all with STARTTLS. It does not offer implicit TLS on 465, so use 587 with secure: false (Nodemailer) or starttls() (Python). Check your provider's docs for the exact list.
Which port should you use?
1Sending from an app or script?2├── Yes → 587 (STARTTLS)3│ └── Blocked or timing out? → your provider's alternate (2525, 2587) or 465 if offered4└── No, I run a mail server receiving mail → 25 inboundOr skip SMTP entirely. If you control the code, an HTTP email API avoids port blocking altogether because it runs on 443. It also gives you structured errors, idempotency and attachments without MIME encoding. See how to send email in Node.js for both approaches side by side.
Configuration examples
All examples use Reloop's SMTP relay. The username can be any string, and the password is your API key (full SMTP docs).
Nodemailer (Node.js)
1import nodemailer from "nodemailer";2
3const transporter = nodemailer.createTransport({4 host: "smtp.reloop.sh",5 port: 587,6 secure: false, // STARTTLS. Reloop does not offer port 4657 auth: {8 user: "reloop",9 pass: process.env.RELOOP_API_KEY,10 },11});Python smtplib
1import os2import smtplib3from email.message import EmailMessage4
5msg = EmailMessage()6msg["From"] = "Acme <hello@mail.acme.com>"7msg["To"] = "user@example.com"8msg["Subject"] = "Hello"9msg.set_content("Sent over port 587 with STARTTLS.")10
11with smtplib.SMTP("smtp.reloop.sh", 587) as server:12 server.starttls()13 server.login("reloop", os.environ["RELOOP_API_KEY"])14 server.send_message(msg)For a provider that offers port 465, replace smtplib.SMTP(...) and starttls() with smtplib.SMTP_SSL(host, 465). With Reloop, stay on 587 and use 2587 if 587 is blocked.
Environment variables (most frameworks)
1SMTP_HOST=smtp.reloop.sh2SMTP_PORT=5873SMTP_SECURE=false4SMTP_USER=reloop5SMTP_PASSWORD=rl_your_api_keyLaravel, Django, Rails, Ghost, Supabase Auth and most CMSs accept these values directly.
Troubleshooting SMTP connections
Test whether a port is open
1# STARTTLS ports (587, 2525, 2587)2openssl s_client -starttls smtp -connect smtp.reloop.sh:587 -crlf3
4# Implicit TLS (465), for providers that offer it5openssl s_client -connect smtp.example.com:465 -crlf6
7# Plain TCP reachability8nc -vz smtp.reloop.sh 587If nc times out, the port is blocked between you and the server. Try the next port.
Common errors
ETIMEDOUT / Connection timed outwrong version number / ECONNRESETsecure: false on port 465secure: true or use 587secure: true on port 587secure: false530 5.7.0 Must issue a STARTTLS command firstAUTH before TLSstarttls() or enable requireTLS535 5.7.8 Authentication failed554 5.7.1 Relay access deniedFrom domain not verifiedself signed certificateOnce mail is flowing, make sure it lands in the inbox: set up SPF, DKIM and DMARC and check the Gmail and Yahoo sender requirements.
FAQ
Both encrypt the whole session when configured correctly. Port 465 starts TLS immediately, so there is no plain-text phase at all. RFC 8314 prefers implicit TLS for that reason. Port 587 is equally safe when the server refuses authentication before STARTTLS, which every reputable provider does.
Cloud and residential providers block outbound port 25 to stop compromised machines from sending spam directly to mail servers. Use 587 or 465 to send through a provider instead. If you need port 25 to deliver mail yourself, ask your host to unblock it, but expect a review.
For sending through Gmail's own SMTP server (smtp.gmail.com), use 587 with STARTTLS or 465 with implicit TLS. Gmail receives mail from other servers on port 25.
No. It is a convention some providers adopted as a fallback when 587 is blocked. It is not registered with IANA, so check that your provider actually listens on it.
Use SMTP when the software only speaks SMTP, such as a CMS, Supabase Auth or a legacy app. Use the HTTP API when you write the code: it runs on port 443, returns structured errors and avoids MIME encoding.
Ship your first email with Reloop
in minutes.
Open-source, deliverability-focused, and yours to self-host or run on Reloop Cloud. No lock-in, no rewrite later.


