New: mailX now works inside ChatGPT. Try it →
SMTP Port Guide

SMTP Ports Explained: 25, 465, 587 and 2525 (and Which One to Use)

Use port 587 with STARTTLS or port 465 with implicit TLS to send email from an app or email client. Port 25 is for server-to-server delivery. Pick your provider below to see the exact ports it supports.

Results

  • Based on RFC 8314 and RFC 6409
  • Ports for nearly 100 providers
  • Free, no signup

SMTP ports at a glance

There are four SMTP ports you will meet in practice. Two are made for sending from an app or email client (587 and 465), one is for mail servers talking to each other (25), and one is an unofficial fallback offered by sending services (2525).

PortEncryptionWhat it is forUse it to send from an app?
587STARTTLS (upgrades to TLS after connecting)Message submission from apps and email clients (RFC 6409)Yes, the default choice
465Implicit TLS (encrypted from the first byte)Message submission over TLS (RFC 8314)Yes, as secure as 587
25Optional STARTTLSRelay between mail servers (RFC 5321)No, usually blocked by ISPs and cloud hosts
2525STARTTLSUnofficial alternative to 587 offered by sending servicesOnly if 587 and 465 are blocked

Short answer: use 587 with STARTTLS. If your app only offers SSL/TLS from the start of the connection, use 465. Never configure port 25 in an app, and keep 2525 for networks that block the standard ports.

Which SMTP port should you use?

Port 587: the default for sending

Port 587 is the official message submission port. The connection starts in plain text, then the client sends the STARTTLS command and the session switches to TLS before you log in. Almost every email provider and sending service supports it, and it is the port to try first.

Port 465: implicit TLS, fully standard again

Port 465 opens an encrypted connection immediately, with no plain-text step. It was deprecated for years, which is why some old guides still say to avoid it, but RFC 8314 (2018) registered it again as the "submissions" port. The RFC asks clients and servers to support both 587 and 465 and states there is no significant security difference between them when they are implemented correctly.

Port 25: server-to-server relay

Port 25 is how mail servers deliver messages to each other. It is not meant for apps that log in to send. Most residential ISPs and cloud providers block or restrict outbound port 25 to fight spam, so an app configured on 25 usually times out.

Port 2525: the unofficial fallback

Port 2525 is not registered for SMTP, but sending services such as SendGrid, Mailgun, Brevo, Postmark and Mailjet accept it as a copy of port 587. It helps when a hosting provider blocks the standard ports.

Exceptions to know

Microsoft 365 does not support port 465 for authenticated sending: use 587, or 25 for SMTP relay through a connector. AOL documents 465 only, iCloud documents 587 only. When in doubt, check your provider in the finder above.

SMTP ports by provider

These are the outgoing servers and ports returned by the mailX SMTP Finder for the most used mailbox providers and sending services. The first port listed is the one to try first.

ProviderSMTP serverPorts
Gmail and Google Workspacesmtp.gmail.com587 STARTTLS, 465 SSL
Microsoft 365smtp.office365.com587 STARTTLS, 25 (465 not supported)
Outlook.com, Hotmailsmtp-mail.outlook.com587 STARTTLS
Yahoo Mailsmtp.mail.yahoo.com465 SSL, 587 STARTTLS
iCloud Mailsmtp.mail.me.com587 STARTTLS
AOL Mailsmtp.aol.com465 SSL
Zoho Mail (US)smtp.zoho.com465 SSL, 587 STARTTLS
GoDaddy Professional Emailsmtpout.secureserver.net465 SSL, 587 STARTTLS
SendGridsmtp.sendgrid.net587, 2525, 25 STARTTLS, 465 SSL
Mailgun (US)smtp.mailgun.org587, 2525, 25 STARTTLS, 465 SSL
Amazon SES (us-east-1)email-smtp.us-east-1.amazonaws.com587, 2587, 25 STARTTLS, 465, 2465 SSL
Brevosmtp-relay.brevo.com587, 2525 STARTTLS, 465 SSL
Postmarksmtp.postmarkapp.com587, 2525, 25 STARTTLS (465 not supported)
How it works

How to test an SMTP port

Four checks to find out whether a port works from where you send.

01

Find your provider's ports

Pick your provider in the finder above. It lists the server and every port with its encryption.

02

Start with 587 and STARTTLS

Set the server, port 587, STARTTLS (sometimes called TLS) and authentication on. If the app only offers SSL/TLS, use 465.

03

Run the mailX SMTP Test

Enter the same host, port, encryption and login. The test tells you whether the server answers, whether TLS works and whether your login is accepted.

04

Test from the sending machine

A port can be open from your laptop and blocked from your server. Run the command line checks below on the machine that will send.

Check an SMTP port from the command line

These commands open a connection to the server. A greeting that starts with 220 means the port is reachable. Replace smtp.gmail.com with your provider's server.

Port 587 with STARTTLS (macOS, Linux, WSL):

openssl s_client -starttls smtp -connect smtp.gmail.com:587 -crlf

Port 465 with implicit TLS:

openssl s_client -connect smtp.gmail.com:465 -crlf

Is the port open at all? (Windows PowerShell):

Test-NetConnection smtp.gmail.com -Port 587

Why your SMTP port does not work

The usual errors and what they mean.

Connection timed out

The port is blocked on your network, by your host or by a firewall. Try 587 or 465, or 2525 with a sending service.

Port 25 blocked by your ISP or cloud

Residential ISPs and most cloud providers block or restrict outbound port 25. Use 587 or 465 to send through your provider.

TLS or SSL handshake error

The port and encryption do not match: 587 goes with STARTTLS, 465 with SSL/TLS. Swap them and try again.

530 Must issue a STARTTLS command first

The server refuses to log you in over plain text. Turn on STARTTLS for port 587.

535 Authentication failed

The port works but the login does not. Gmail, Yahoo, AOL and iCloud need an app password or OAuth in third-party apps.

Port 465 refused by Microsoft 365

Microsoft 365 only accepts authenticated sending on 587 (or 25 through a connector). Switch to 587.

Port open, login accepted? Check what happens next.

Your emails reach the inbox when SPF, DKIM and DMARC are set up for your domain. Check all three in one free test.

SMTP Ports FAQ

Choosing a port

What is the default SMTP port?
Port 587 with STARTTLS is the default port to send email from an app or email client. Port 25 is the default between mail servers, not for apps.
Should I use port 587 or 465?
Both are encrypted and both are standard. Use 587 with STARTTLS by default, and 465 when your app only offers SSL/TLS from the start of the connection. RFC 8314 asks servers to support both.
Is port 465 deprecated?
No longer. It was deprecated for a while, but RFC 8314 (2018) registered it again for message submission over implicit TLS. Some providers, such as Microsoft 365 and Postmark, still do not accept it.
What is port 2525 used for?
It is an unofficial copy of port 587 offered by sending services like SendGrid, Mailgun, Brevo and Postmark, for networks that block the standard ports.

Port 25

Why is port 25 blocked?
Spam. Infected computers used to send spam directly on port 25, so most ISPs and cloud providers block or restrict it for outgoing connections. Use 587 or 465 to send through your provider.
Can I send email on port 25?
Only server to server, or through a relay that accepts it, such as a Microsoft 365 connector. For an app that logs in to send, use 587 or 465.

Testing and errors

How do I check which SMTP port my provider uses?
Pick your provider in the mailX SMTP Finder. It lists the outgoing server and every supported port with its encryption.
How do I test if an SMTP port is open?
Run the mailX SMTP Test with your server, port and login, or use openssl s_client or Test-NetConnection from the machine that will send.
What is the difference between SSL, TLS and STARTTLS?
SSL is the old name of TLS. STARTTLS starts in plain text and upgrades to TLS (port 587). Implicit TLS, often labeled SSL/TLS in apps, is encrypted from the first byte (port 465).