SMTP guide

SMTP ports 25, 465, 587 and 2525: differences and which to use

Each port has a role and an encryption type. Picking the right one avoids most connection and TLS errors when you set up an application or a plugin.

What an SMTP port is

A mail server listens on several ports, and each one is meant for a type of connection. Some let servers pass email between themselves; others let an application, a plugin or an email client hand its messages to its sending server.

If your application sends through an SMTP service, the norm is port 587 with STARTTLS or 465 with implicit TLS. Port 25 is for server-to-server traffic and 2525 is a non-standard alternative that only some providers offer.

Short answer

Use 587 with STARTTLS or 465 with SSL/TLS, always with authentication. Don't use 25 to send from an application: it's for server-to-server traffic and many providers block it. 2525 only helps if your provider offers it.

Overview

The four ports at a glance

PortWhat it's forEncryptionFor your application?
25Relaying email between servers (RFC 5321)Optional STARTTLS, when both servers support itNo: it's often blocked and isn't meant for clients
587Message submission from applications and email clients (RFC 6409)STARTTLS: the connection starts unencrypted and is encrypted before authenticatingYes, the most compatible
465Message submission over implicit TLS (RFC 8314)TLS from the very startYes, equally valid
2525Non-standard alternative some providers offerDepends on the providerOnly if your provider offers it

With Mailiqo: smtpmq.mailiqo.com on 587 with STARTTLS or on 465 with SSL/TLS. Ports 25 and 2525 aren't available.

Port 25

Port 25: between servers, not for your application

Port 25 is SMTP's original port. Mail servers use it to deliver messages to each other: when your sending service hands an email to the recipient's server, it does so on port 25.

Because it was used for years to send spam from infected machines, many internet providers, hosts and clouds block outbound connections to port 25, or only open them on request. That's why an application trying to send on 25 often hangs until the connection times out.

For an application to hand over its messages there's the submission port, with mandatory authentication: 587 or 465.

Port 587

Port 587: the standard, with STARTTLS

587 is the message submission port defined in RFC 6409. The connection starts unencrypted, the client sends the STARTTLS command (RFC 3207) and from then on everything is encrypted, including the username and password.

It's the most compatible port: practically every plugin, library and email client supports it. In settings it usually shows up as TLS or STARTTLS encryption.

  • If you choose SSL on 587, the connection fails with errors such as wrong version number.
  • If you don't turn on encryption, the server can reject authentication with 530 5.7.0 Must issue a STARTTLS command first.
Port 465

Port 465: TLS from the first byte

On 465 the connection is encrypted from the start (implicit TLS), before any SMTP command is exchanged. In settings it usually shows up as SSL, SSL/TLS or SMTPS.

For a while it was considered obsolete, but RFC 8314 (2018) registered it again for message submission and recommends implicit TLS over STARTTLS. Today both ports are valid and secure: pick the one that works on your network and that your application supports.

Port 2525

Port 2525: an unofficial alternative

IANA hasn't assigned 2525 to SMTP. Some providers offer it as an alternative when the host blocks the usual ports, and it usually works like 587, with STARTTLS.

If your provider doesn't offer it, there's no point trying it. Mailiqo doesn't use it: if your network blocks 587 and 465, the alternative is to send through the API, which works over HTTPS on port 443.

Check

How to check whether a port is open

Test from the server where your application runs, not from your computer: the block is usually on the host's network. With openssl you check that the port answers and that TLS works at the same time:

openssl s_client -starttls smtp -connect smtpmq.mailiqo.com:587 -servername smtpmq.mailiqo.com
openssl s_client -connect smtpmq.mailiqo.com:465 -servername smtpmq.mailiqo.com

# Windows (PowerShell)
Test-NetConnection smtpmq.mailiqo.com -Port 587

If openssl shows the server's certificate, the port is open and TLS works. If it hangs until it times out, a firewall is blocking the connection: try the other port or ask your provider to open it.

Which one

Which one to use in practice

  • By default, 587 with STARTTLS: it's what Mailiqo's documentation recommends and what almost every application supports.
  • If 587 is blocked on your network or your application prefers implicit TLS, 465 with SSL/TLS.
  • Never 25 from an application, and never turn encryption off to make it work.
  • If both are blocked and you can't get them opened, send through an API over HTTPS.
FAQ

Frequently asked questions

Which SMTP port is more secure, 465 or 587?

Both encrypt the connection before the username and password are sent. The difference is when: 465 encrypts from the start and 587 does it with STARTTLS after connecting. RFC 8314 prefers implicit TLS, but configured properly both are secure.

Why does my host block port 25?

To stop compromised sites or misconfigured servers from sending spam straight from its network. You don't need it to send from an application: use 587 or 465 with an SMTP service.

Can I use port 25 with Mailiqo?

No. Mailiqo accepts sending on 587 with STARTTLS and on 465 with SSL/TLS, always with authentication.

What do TLS, SSL and STARTTLS mean in the settings?

SSL is the old name for TLS, and many programs still use it for implicit TLS on 465. STARTTLS, sometimes labelled TLS, is the encryption that starts after connecting, the one used on 587.

What if my provider blocks both 587 and 465?

Ask them to open one of them. If that isn't possible, send with the Mailiqo API, which works over HTTPS (port 443), the same port any website uses.

Mailiqo

SMTP on 587 and 465, with your domain

Mailiqo accepts sending on 587 with STARTTLS and on 465 with SSL/TLS, and through the API when SMTP ports are blocked. Start free, no card required.

Create a free account
Mailiqo Labs

Put the guide into practice

The tools let you check SPF, DMARC, headers, bounces and HTML with your own data, without registering.