Groundmail

Guides

SMTP ports: which one to use, and why

Which SMTP port to use: 587 (STARTTLS) or 465 (implicit TLS) to send, 25 between mail servers, 2525 as a fallback. Why port 25 is blocked and how to test.

By Groundmail

Short answer

Use port 587 with STARTTLS to send email from an app or mail client through an SMTP server, or port 465 with implicit TLS if your provider offers it; both are standard and equally secure when TLS is required. Port 25 is for server-to-server delivery between mail servers, and most cloud hosts block it for outbound traffic. Port 2525 isn't a standard, but many providers accept it as a fallback when a network blocks the others.

The SMTP mail port your app uses only covers the hop to your provider. Your provider then delivers to Gmail, Outlook and the rest over port 25.

On this page

Which SMTP port should I use?

Your situationPortEncryption
Sending from an app, framework or mail client (the default)587STARTTLS
Your provider supports it and your client prefers TLS from the first byte465Implicit TLS
587 and 465 are blocked by your host or network2525, if your provider offers itUsually STARTTLS
Running a mail server that delivers to other mail servers (MX to MX)25Opportunistic STARTTLS
Every SMTP port is blockedNone: send over an HTTPS email API on port 443TLS

If a guide, plugin or dashboard asks for an "SMTP port" and you're configuring an app to send through a provider, it almost always wants 587. Check your provider's settings page for the exact host, port and encryption it supports, then match the encryption setting to the port (see the client settings below).

What each SMTP port is for

PortOfficial useTLSTypical use today
25SMTP relay between mail servers (RFC 5321)STARTTLS, optionalMail servers delivering to each other's MX records
587Message submission (RFC 6409)STARTTLSApps and mail clients sending through a provider, with a login
465Message submission over TLS (RFC 8314)Implicit TLSSame as 587, encrypted from the start
2525None (not registered for mail)Usually STARTTLSA fallback some providers offer for blocked networks

Port registrations as listed in the IANA service name and port number registry.

Port 25: server-to-server delivery

Port 25 is the original SMTP port and still the only one mail servers use to deliver to each other. When Gmail receives mail for a gmail.com address, the sending server looks up gmail.com's MX record and connects on port 25; MX records have no way to name another port. So port 25 isn't going away, but it's for mail servers, not for apps.

Encryption on port 25 is opportunistic: the receiving server offers STARTTLS and the sender uses it if it can. Port 25 also doesn't expect a login, which is exactly why it attracts abuse from compromised machines and is blocked on most cloud and residential networks.

Port 587: message submission with STARTTLS

RFC 6409 split "submitting" a message (your app handing it to a provider) from "relaying" it (provider to recipient), and reserved port 587 for submission. A submission server expects the client to log in before it accepts mail.

The connection starts in plain text. The server lists its capabilities, including STARTTLS; the client sends STARTTLS, both sides negotiate TLS, and the login and message travel inside the encrypted session. A well-configured server won't accept a password before the upgrade.

Port 465: submission with implicit TLS

On port 465, the TLS handshake happens as soon as the TCP connection opens, before any SMTP is spoken. Port 465 was briefly registered as "smtps" long ago and then revoked, which is why older guides call it deprecated. RFC 8314 (2018) registered it again as "submissions", for message submission over TLS, so it's a current standard.

RFC 8314 recommends implicit TLS for submission, asks clients and servers to support both 587 with STARTTLS and 465 during a transition, and notes there's no significant security difference between the two when both sides require TLS before sending.

Port 2525: the unofficial fallback

Port 2525 isn't assigned to SMTP by any standard; IANA lists it for an unrelated service. Several email providers listen on it anyway, with the same STARTTLS behavior as 587, because networks that block mail ports rarely think to block 2525. Use it only when your provider documents it and the standard ports are blocked.

STARTTLS vs implicit TLS

STARTTLS (587, 25, usually 2525)Implicit TLS (465)
When TLS startsAfter EHLO and a STARTTLS commandImmediately, before any SMTP
First thing the server sendsA plain-text 220 greetingIts TLS certificate
Client setting"STARTTLS", "TLS" or secure: false"SSL/TLS", "SSL" or secure: true
Risk if misconfiguredA client that doesn't require TLS can be downgraded to plain textNone from downgrade: no TLS, no session

Why port 25 is blocked on cloud hosts

Port 25 needs no login, so a compromised or rented server can use it to deliver spam straight to anyone's mail server. Cloud providers block outbound port 25 to keep their IP ranges off blocklists, and many residential ISPs do the same. Some go further and block the submission ports too. Here is what the major clouds document:

HostPort 25 outboundPorts 587 and 465
AWS EC2Blocked to public IPv4 and IPv6 addresses by default; you can request removalNo restriction documented (the limit is on port 25)
Google Cloud Compute EngineBlocked to external destinations, apart from some projects that have no restrictionNot restricted, per Google's docs
Microsoft Azure VMsBlocked except on Enterprise Agreement and MCA-E subscriptions; Enterprise Dev/Test can request removal587 not restricted on any subscription
DigitalOcean DropletsBlocked by defaultAlso blocked by default (25, 465 and 587)

From each provider's documentation. Policies change, so check your own account if a connection fails.

Last checked on each vendor's public page.

Even where port 25 is open, sending straight to Gmail or Outlook from a cloud server rarely delivers well: the IP has no sending reputation, and you'd run the queue, retries and bounce handling yourself. Send through an SMTP relay on 587 or 465, or through an email API over HTTPS, and let the provider handle port 25.

Worked example: Groundmail's SMTP relay

Groundmail's SMTP relay listens on port 587 with STARTTLS. It doesn't listen on 465 or 2525, so a client pointed at those ports times out. The relay refuses a login before STARTTLS, so passwords never cross the network in plain text. Check it, and your credential, with the SMTP tester.

Groundmail SMTP settings

Host:        smtp.groundmail.dev
Port:        587
Encryption:  STARTTLS
Username:    groundmail
Password:    gmsmtp_…   # an SMTP credential from the dashboard

From:        noreply@yourdomain.com   # a domain you verified

If your host blocks 587 too, as DigitalOcean does by default, send with the Groundmail API instead: it's a single HTTPS request on port 443, with the same domains, suppressions and webhooks as the relay.

Port and TLS settings in common clients

Clients name the TLS options differently. For port 587, pick the STARTTLS option; for 465, pick the implicit TLS one.

ClientPort 587 (STARTTLS)Port 465 (implicit TLS)
Nodemailer (Node.js)secure: false (upgrades automatically; add requireTLS: true to insist)secure: true
DjangoEMAIL_USE_TLS = TrueEMAIL_USE_SSL = True
Python smtplibSMTP(host, 587) then starttls()SMTP_SSL(host, 465)
Laravel 11+ / Symfony MailerMAIL_SCHEME=smtp (STARTTLS is used when offered)MAIL_SCHEME=smtps
PHPMailerSMTPSecure = PHPMailer::ENCRYPTION_STARTTLSSMTPSecure = PHPMailer::ENCRYPTION_SMTPS
WordPress SMTP plugins and similar settings screens"TLS" or "STARTTLS""SSL" or "SSL/TLS"

Nodemailer on port 587

import nodemailer from "nodemailer";

const transport = nodemailer.createTransport({
  host: "smtp.groundmail.dev",
  port: 587,
  secure: false,    // plain connect, then STARTTLS
  requireTLS: true, // fail instead of sending without TLS
  auth: { user: "groundmail", pass: process.env.GROUNDMAIL_SMTP_PASSWORD },
});

How to test an SMTP port

For a quick check from the internet, the free SMTP tester connects to your server, upgrades to TLS, checks the certificate and tries your login, showing every reply. To test the path your app takes, run the commands below from the machine that will send the mail: a port that's open from your laptop can still be blocked from your server.

  1. 1

    Check the port is reachable

    nc -vz smtp.groundmail.dev 587 (or telnet smtp.groundmail.dev 587) should connect within a second or two. On Windows, use Test-NetConnection smtp.groundmail.dev -Port 587 in PowerShell. A hang that ends in a timeout means something is dropping the traffic; "connection refused" means nothing is listening there.

  2. 2

    Check the TLS handshake and certificate

    Use openssl s_client (below). Look for verify return:1 on each certificate in the chain and a final certificate whose name matches the host you connected to.

  3. 3

    Check what the server offers

    Type EHLO yourhost.example once connected. After the upgrade on 587, or straight away on 465, the reply should list AUTH with the mechanisms your client uses, usually PLAIN or LOGIN. Type QUIT to close.

Port 587 (STARTTLS)

openssl s_client -starttls smtp -crlf \
  -connect smtp.groundmail.dev:587 -servername smtp.groundmail.dev

Port 465 (implicit TLS)

openssl s_client -crlf \
  -connect smtp.example.com:465 -servername smtp.example.com

What a healthy 587 session looks like (trimmed)

depth=0 CN=smtp.groundmail.dev
verify return:1
...
EHLO yourhost.example
250-smtp.groundmail.dev
250-PIPELINING
250-8BITMIME
250-SMTPUTF8
250 AUTH LOGIN PLAIN
QUIT
221 Bye

Troubleshooting SMTP connection errors

SymptomLikely causeFix
Connection times outYour host, ISP or an egress firewall rule drops the port, or the server doesn't listen on itTest with nc from the sending machine. Try 465 or 2525 if your provider offers them, ask your host to lift the block, or send over an HTTPS API
Connection refusedNothing listening on that host and port: wrong port, wrong host, or a local firewall rejecting itCheck the host and port against your provider's settings page
wrong version number, SSL routines or a handshake failureTLS setting doesn't match the port: implicit TLS on 587, or STARTTLS on 465587 with STARTTLS (secure: false), or 465 with implicit TLS (secure: true)
Certificate name mismatch or "self-signed certificate in chain"Connecting by IP or an alias instead of the provider's hostname, an out-of-date CA bundle, or a proxy or antivirus inspecting TLSUse the exact hostname from your provider, update CA certificates, bypass the inspecting proxy. Don't turn off certificate checks
538 5.7.11 or "Must issue a STARTTLS command first"The client tried to log in before upgrading to TLSEnable STARTTLS in the client (on Nodemailer, requireTLS: true)
535 5.7.8 authentication credentials invalidWrong username or password, a revoked credential, or an API key used where an SMTP password is expectedRe-copy the credential, or create a new one. On Groundmail the username is always groundmail
530 5.7.0 authentication required, or "Relay access denied"The client sent mail without logging inTurn on SMTP authentication in the client. See 554 5.7.1

The 5xx auth codes are defined in RFC 4954.

Once the connection works, delivery errors come back as bounce codes from the recipient's server, such as 550 5.7.26 for failed authentication or 550 5.1.1 for an address that doesn't exist. The SMTP error codes reference explains each one.

Frequently asked questions

What is the SMTP port?

There are four in common use. Port 587 (STARTTLS) and port 465 (implicit TLS) are for sending mail from apps and mail clients through a provider. Port 25 is for mail servers delivering to each other. Port 2525 is an unofficial fallback some providers offer.

Should I use port 587 or 465?

Either works and both are standards. Use 587 with STARTTLS if you're unsure, since almost every provider supports it. Use 465 if your provider offers it and your client is set to implicit TLS. RFC 8314 recommends implicit TLS for submission but asks for both to be supported.

Is port 465 deprecated?

No. It was briefly registered as "smtps" long ago and then revoked, which is where the idea comes from, but RFC 8314 registered it again in 2018 for message submission over implicit TLS.

Why can't I send email on port 25?

Most cloud hosts and home ISPs block outbound port 25 to stop spam. AWS, Google Cloud, Azure (outside enterprise agreements) and DigitalOcean all block it by default. Send through an SMTP relay on 587 or 465 instead.

What is the SMTP mail port for Gmail or Outlook?

When you send through a mailbox provider's own SMTP server with a login, use 587 with STARTTLS (or 465 where offered). For app email such as password resets, send through a transactional provider from your own domain instead of a personal mailbox.

What port does Groundmail's SMTP relay use?

Port 587 with STARTTLS, on smtp.groundmail.dev, with the username groundmail and an SMTP credential as the password. If your host blocks 587, send with the HTTPS API on port 443.

Is port 2525 secure?

It's as secure as the TLS setting on it. Providers that offer 2525 usually support STARTTLS there, the same as 587, so require TLS in your client.

Sources

Facts on this page about other companies' products, prices and policies come from these public pages. They change, so check them before you decide.

Send from infrastructure we own.

Groundmail runs its own mail servers on its own IP space. Start free on the shared transactional pool, then move to dedicated IPs or a dedicated server without changing your code.