SMTP ports
SMTP Ports 25, 465 and 587: Which One Should You Use?
Use port 587 with STARTTLS to send mail from an app, website or email client: it is the standard mail submission port. Port 465 (implicit TLS) is equally valid and recommended by RFC 8314. Port 25 is for server-to-server relay between mail servers, and most ISPs and cloud providers block outbound port 25 to stop spam. Port 2525 is an unofficial fallback some email services offer when 587 is blocked.
- Recommended for sending
- 587 (STARTTLS)
- Implicit TLS
- 465 (SMTPS)
- Server-to-server relay
- 25
- Unofficial alternative
- 2525
- Transport
- TCP
Last updated:
SMTP ports compared
STARTTLS starts as plain text and upgrades to TLS after the STARTTLS command. Implicit TLS on 465 negotiates TLS immediately, like HTTPS. Both are secure when the client refuses to continue without TLS.
| Port | Purpose | Encryption | Use it for |
|---|---|---|---|
| 25 | Mail relay (MTA to MTA) | Optional STARTTLS | Mail servers receiving mail from other mail servers |
| 587 | Message submission | STARTTLS, required for login | Apps, websites and email clients sending mail |
| 465 | Message submission | Implicit TLS from the first byte | Clients and libraries that prefer TLS-only connections |
| 2525 | Unofficial submission | Usually STARTTLS | A fallback when your network blocks 587 and 465 |
Which SMTP port should I use?
- Sending from an app, CMS, printer or email client: use 587 with STARTTLS. If your provider documents 465, that works just as well.
- Running a mail server that receives mail from the internet: accept connections on 25, and offer 587 and 465 for your own users.
- 587 is blocked on your network: try 465, then 2525 if your email service supports it.
- Never send a username and password over port 25 without TLS.
SMTP server and port settings for popular providers
Gmail and Microsoft 365 no longer accept your normal account password from most apps. Use an app password or OAuth 2.0, otherwise the connection succeeds but login fails with a 535 error.
| Provider | SMTP server | Ports |
|---|---|---|
| Gmail / Google Workspace | smtp.gmail.com | 587 (STARTTLS), 465 (TLS) |
| Outlook.com / Microsoft 365 | smtp.office365.com | 587 (STARTTLS) |
| Yahoo Mail | smtp.mail.yahoo.com | 465 (TLS), 587 (STARTTLS) |
| iCloud Mail | smtp.mail.me.com | 587 (STARTTLS) |
| Zoho Mail | smtp.zoho.com | 465 (TLS), 587 (STARTTLS) |
| Amazon SES | email-smtp.REGION.amazonaws.com | 587, 2587 (STARTTLS); 465, 2465 (TLS) |
| SendGrid | smtp.sendgrid.net | 587, 2525, 25 (STARTTLS); 465 (TLS) |
Why is port 25 blocked?
Port 25 is where malware-infected computers used to send spam directly to other mail servers. To stop that, most residential ISPs block outbound connections to port 25, and many cloud providers, including AWS, Google Cloud and Microsoft Azure, restrict outbound port 25 on virtual machines by default.
This only affects sending to port 25. Users should submit mail on 587 or 465, which are rarely blocked. If you run your own mail server in the cloud, ask the provider to lift the restriction or relay outbound mail through an email delivery service.
How to test an SMTP port
The open port checker tests whether a mail server accepts connections from the internet. The port scanner Mail preset checks 25, 110, 143, 465, 587, 993 and 995 at once and shows the server greeting. To test whether your own network can reach a provider, run these commands from your computer:
Windows PowerShell
Test-NetConnection smtp.gmail.com -Port 587Check the TLS handshake with OpenSSL
The first command tests STARTTLS on 587, the second tests implicit TLS on 465. A working server prints its certificate and a 250 response.
openssl s_client -starttls smtp -connect smtp.gmail.com:587
openssl s_client -connect smtp.gmail.com:465Read the server greeting on port 25
A mail server answers with a 220 banner. No answer at all usually means your ISP blocks outbound port 25.
nc -v mail.example.com 25Common SMTP connection errors
| Error | Meaning | Fix |
|---|---|---|
| Connection timed out | A firewall or ISP dropped the connection. | Try 587 or 465 instead of 25, and check outbound firewall rules. |
| Connection refused | The host is reachable but nothing listens on that port. | Check the server name and port, and that the mail service is running. |
| 530 5.7.0 Must issue a STARTTLS command first | The client tried to log in before encrypting. | Enable STARTTLS (or TLS) in the client settings. |
| 535 5.7.8 Authentication failed | Wrong credentials or basic authentication is disabled. | Use an app password or OAuth 2.0. |
| Certificate or hostname mismatch | The server name does not match its TLS certificate. | Use the exact SMTP host name from your provider. |
Opening SMTP ports on your own mail server
- Allow inbound 25 for mail from other servers, and 587 and 465 for your users, for example
sudo ufw allow 25,465,587/tcp. - Require authentication on 587 and 465, and never allow unauthenticated relaying (an open relay gets blacklisted within hours).
- Set up reverse DNS (PTR), SPF, DKIM and DMARC, or other servers will reject or spam-folder your mail.
- Incoming mail for your users is read over IMAP or POP3; see POP3 and IMAP ports.
SMTP port FAQ
Should I use SMTP port 587 or 465?
Both are secure for sending mail. 587 uses STARTTLS and is the most widely supported submission port. 465 uses implicit TLS and is recommended by RFC 8314. Use whichever your provider documents.
Is port 587 TLS or SSL?
Port 587 starts unencrypted and upgrades with STARTTLS. Port 465 uses SSL/TLS from the start. In client settings, 587 usually maps to STARTTLS and 465 to SSL/TLS.
Why can't I send mail on port 25?
Most ISPs and cloud providers block outbound port 25 to prevent spam. Submit mail on 587 or 465 instead. Port 25 is meant for mail servers talking to each other.
What is port 2525 used for?
2525 is not an official SMTP port, but services such as SendGrid accept it as an alternative to 587 when a network blocks the standard ports.
Does SMTP use TCP or UDP?
SMTP uses TCP only. Ports 25, 465 and 587 never carry SMTP over UDP.
How do I check if my SMTP port is open?
Enter your mail server and port 587 or 25 in the open port checker. From your own computer, run Test-NetConnection smtp.example.com -Port 587 on Windows or nc -v smtp.example.com 587 on macOS and Linux.
References
- RFC 8314: Cleartext Considered Obsolete — recommends implicit TLS on 465 for submission.
- RFC 6409: Message Submission for Mail — defines port 587.
- RFC 5321: Simple Mail Transfer Protocol — the SMTP specification.
- IANA Service Name and Port Number Registry — official port assignments.