Knowledgebase

Find frequently asked questions and setup guides by searching or by browsing the categories.

SMTP Ports at a Glance

PortUsed forEncryption
25Server to server relaySTARTTLS if offered
587Submission by clientsSTARTTLS, then login
465Submission by clientsTLS from the start
2525Unofficial fallbackUsually as on 587

The short answer: an application, a contact form, or a mail client sends on 587 or 465 with a user name and password. Port 25 is for mail servers delivering to each other.

Port 25: Relay Between Mail Servers

When a mail server delivers a message to another domain, it looks up that domain's MX record and connects to port 25 of the host it names. No login takes place: the receiving server accepts mail for its own domains and judges the sender by its IP address, reverse DNS, and sender records. Details and the usual restrictions are in port 25.

Port 587: Submission

Port 587 is the submission port. The client connects in plain text, upgrades the connection with the STARTTLS command, and then logs in. The server accepts mail to any destination only after a successful login, and passes it on through port 25. This is the default choice for applications. See port 587.

Port 465: Submission with Implicit TLS

On port 465 the TLS handshake happens first, before any SMTP command, the same way HTTPS works on port 443. It was once withdrawn, then designated again for submission by RFC 8314, which recommends implicit TLS over STARTTLS. Many services accept both 465 and 587; either is fine when the client is set to the matching mode.

Port 2525: An Unofficial Alternative

Port 2525 is not assigned to SMTP. Some relay services listen on it for networks that block the usual ports. It normally behaves like 587, with STARTTLS and a login. Use it only when the service documents it.

Which Port Should You Use?

  • Application or contact form: 587 with STARTTLS, or 465 with TLS, plus the account's login.
  • Mail client on a computer or mobile device: the same; take the values your mail service publishes.
  • Your own mail server delivering to the internet: 25, which needs outgoing port 25 to be open.
  • Your own mail server receiving mail: incoming 25, plus 587 or 465 for your users.

Outgoing Port 25 Is Often Restricted

Many providers restrict outgoing connections to port 25 from servers, because compromised machines send spam through it. Check with your provider before you plan direct delivery. Ports 587 and 465 are usually not affected, which is why relaying through a mail service on 587 is the common way out.

Test the Ports from Your Server

A quick reachability check with nc (see nc command):

nc -vz -w 5 smtp.example.com 587

A full check with TLS. On 587 and 25, STARTTLS comes first; on 465, TLS starts at once:

openssl s_client -starttls smtp -connect smtp.example.com:587 -crlf
openssl s_client -connect smtp.example.com:465 -crlf

On 465 the server's greeting, a line starting with 220, appears after the certificate details; on 587 openssl has already read the greeting and sent EHLO and STARTTLS for you. In both cases, type EHLO test.example.com to see what it offers, then QUIT. More options are in openssl s_client.

Common Errors

  • Connection timed out: the port is blocked on the way out, usually 25. Try 587 or 465.
  • TLS handshake error or a hang: the client mode does not match the port, for example STARTTLS set on 465.
  • Relay access denied: mail to another domain was sent without logging in, often on port 25.
  • Authentication failed: wrong user name or password; many services expect the full mailbox address as the user name.

To send a test message from the shell once the port works, see how to send email from the Linux command line.

Was this answer helpful?
Loading...