SMTP ports 25, 587, 465 and 2525: which one should you use?
Use port 587 (STARTTLS) or 465 (implicit TLS) with authentication when an app, device or mail client sends through a mail provider. RFC 8314 prefers implicit TLS on 465, but providers differ. Port 25 is for server-to-server relay and is often blocked by ISPs and cloud hosts. Port 2525 is a non-standard fallback some services offer.
On this page 8 sections
Pick the wrong SMTP port and nothing happens: the connection hangs, the scanner shows a vague error, or the app says "authentication failed" when the password is right. The fix is usually simple once you know what each port is for. This guide gives the short answer, the standards behind it, and a troubleshooting checklist.
Which SMTP port should you use?
Start with what is doing the sending. A mail server delivering to another domain uses port 25. Anything that logs in to a provider to send (a mail app, a website plugin, a scanner, a CRM) should use port 587 or 465.
| Port | Name | Encryption | Authentication | Use it for |
|---|---|---|---|---|
| 25 | SMTP relay | Optional STARTTLS | Not normally | Server-to-server delivery to MX hosts |
| 587 | Submission | STARTTLS (upgrade after connecting) | Required | Apps, devices and mail clients sending through a provider |
| 465 | Submissions | Implicit TLS (encrypted from the first byte) | Required | Same as 587, where the provider supports it |
| 2525 | Not assigned to mail | Depends on provider | Depends on provider | Fallback offered by some sending services |
If you only remember one thing: 587 or 465 with a username and password (or OAuth) for anything that isn't a mail server. Check which of the two your provider documents, because not every provider supports both.
If you need a refresher on how the SMTP conversation itself works, read what is SMTP first.
What is port 25 for?
Port 25 is the original SMTP port, and it's still the only port used between mail servers. RFC 5321 says a server should keep a listener on "the SMTP port (specified by IANA as port 25) at all times".
There's no alternative for inbound mail. When a server looks up your MX record, it gets a host name and a priority, never a port. As RFC 8314 puts it, "the SMTP transport MX infrastructure has no way to specify a port, so port 25 is always used." Your mail server, or the filtering service in front of it, must accept connections on 25.
Encryption on port 25 is negotiated with STARTTLS and is usually opportunistic: if either side can't do TLS, many servers fall back to plain text. STARTTLS and email encryption in transit explains the risk, and MTA-STS is how a receiving domain makes TLS mandatory.
What is port 587 for?
Port 587 is the submission port. RFC 6409 reserves it "for email message submission", meaning a user's client handing a new message to its own provider. Two rules set it apart from port 25:
- Authentication is required. RFC 6409 says the submission server must, by default, return an error to
MAIL FROMif the session hasn't authenticated, using reply code 530. That's the 530 5.7.0 error you see when a client forgets to log in. - TLS is negotiated with STARTTLS. The client connects in plain text, sees
STARTTLSin the server's EHLO reply, upgrades the connection, then authenticates.
Microsoft 365 uses this port for authenticated client submission. Microsoft Learn lists smtp.office365.com, "587 (recommended) or 25", with TLS 1.2 or 1.3 required.
What is port 465 for?
Port 465 is submission with implicit TLS: the TLS handshake starts as soon as the TCP connection opens, before any SMTP is spoken. It has an odd history. RFC 8314 explains that 465 was "briefly registered as the 'smtps' port", then revoked, but "some widely deployed mail software" kept using it for secure submission anyway. In 2018, RFC 8314 made it official again under the name "submissions".
RFC 8314 also changed the recommendation. It says connections to submission servers should "be made using 'Implicit TLS' ... in preference to connecting to the 'cleartext' port and negotiating TLS using the STARTTLS command". For a transition period, it says clients and servers "SHOULD implement both STARTTLS on port 587 and Implicit TLS on port 465."
It adds an important point: there is "no significant difference between the security properties of STARTTLS on port 587 and Implicit TLS on port 465" if both sides are correct and require TLS before sending. The practical advantage of 465 is that there's no plain-text phase for an attacker to tamper with, and no way for a misconfigured client to carry on without encryption.
Provider support varies
Don't assume 465 works everywhere:
| Provider and service | Ports documented |
|---|---|
Microsoft 365, client SMTP submission (smtp.office365.com) |
587 (recommended) or 25. Microsoft says a device that "recommends or defaults to TCP port 465" doesn't support the required TLS versions for this service. |
| Microsoft 365, SMTP relay connector | 25 to your MX endpoint, authenticated by an inbound connector (certificate or static IP) |
| Microsoft 365, Direct Send | 25 to your MX endpoint, no authentication; internal recipients only |
Google Workspace, Gmail SMTP server (smtp.gmail.com) |
465 for SSL, 587 for TLS (Google also lists 25) |
Google Workspace, SMTP relay service (smtp-relay.gmail.com) |
25, 465 or 587 |
Sources: Microsoft Learn and Google Workspace Admin Help. If you're setting up a scanner or app on Microsoft 365, our scan to email guide compares the three options, and SMTP AUTH and Basic auth retirement covers what changes for password-based sending.
What about port 2525?
Port 2525 isn't an email port in any standard. The IANA port registry lists TCP 2525 for an unrelated service called "MS V-Worlds". Some email sending services accept SMTP on 2525 as an alternative for networks that block 25, 587 or 465.
Treat it as a provider-specific workaround:
- Use it only if your sending service documents it.
- Require TLS and authentication, exactly as you would on 587.
- Expect it to be blocked on some corporate networks, since firewalls often allow only the standard ports outbound.
Why do ISPs and cloud providers block port 25?
Malware on home computers and abused rented servers can send spam straight to receiving mail servers on port 25, bypassing any provider that would notice. Blocking outbound 25 from networks that shouldn't run mail servers closes that path, while legitimate users keep sending through authenticated submission on 587 or 465. Microsoft notes that "some network firewalls or ISPs block port 25 because that port is used by email servers to send messages."
The anti-abuse group M3AAWG still recommends it: "Blocking port 25 for all but a few restricted purposes is still considered an industry best practice." Its advice to providers is to "Provide email submission services on ports 465 and 587" and to require authentication for submission.
The large cloud platforms follow similar rules:
- Microsoft Azure. Microsoft Learn says "The Azure platform blocks outbound SMTP connections on TCP port 25 for deployed VMs" on most subscription types. Standard Enterprise Agreement and MCA-E subscriptions aren't blocked; Enterprise Dev/Test subscriptions are blocked by default but can request an exemption. Microsoft recommends an authenticated SMTP relay on port 587, which "isn't restricted in Azure, regardless of the subscription type."
- Google Cloud. Google's documentation says connections to destination TCP port 25 outside your VPC network "are blocked", though some projects are exempt, and that it does not restrict ports 587 or 465.
- Amazon EC2. AWS says that by default, port 25 traffic "is blocked to public IPv4 addresses and IPv6 addresses", and you can request that the restriction be removed.
Many home and business ISPs block outbound 25 too. If you run a mail server on a network like this, hand outgoing mail to an authenticated relay or smart host on 587 or 465 instead of delivering directly.
How do you troubleshoot SMTP port problems?
Work through these in order. Most problems are found in the first three steps.
- Confirm the host and port pair. Check your provider's documentation for the exact host name, port and encryption mode. A wrong host name (such as an MX host where a submission host is expected) causes confusing errors.
- Match the encryption mode to the port. Port 465 needs implicit TLS, often labeled "SSL" or "SSL/TLS" in settings. Port 587 needs STARTTLS, often labeled "TLS" or "STARTTLS". A mismatch usually shows up as a hang or a garbled handshake error rather than a clear message.
- Test whether the port is reachable. On Windows, run
Test-NetConnection smtp.example.com -Port 587in PowerShell. On macOS or Linux, runopenssl s_client -starttls smtp -connect smtp.example.com:587for STARTTLS oropenssl s_client -connect smtp.example.com:465for implicit TLS. A timeout points to a firewall, ISP or cloud block, not to your credentials. - Read the reply code.
530 5.7.0means the server wants you to authenticate or start TLS first. 535 5.7.8 means the username, password or authentication method was rejected. Look up anything else in the SMTP error code lookup. - Check the TLS version. Old printers and scanners sometimes support only TLS 1.0 or 1.1. Microsoft 365 requires TLS 1.2 or later for client submission, so a firmware update or a local relay may be the only fix.
- Check provider-side settings. In Microsoft 365, SMTP AUTH must be enabled for the mailbox; Microsoft says it's disabled for organizations created after January 2020 but can be enabled per mailbox.
- Send a test and read the headers. Once mail goes out, send to an outside mailbox and check SPF, DKIM and DMARC in the deliverability test. A message that sends but lands in spam is an authentication problem, not a port problem.
Next steps
- Set every app, scanner and website plugin to 587 or 465 with authentication, and note which mode each uses.
- If anything still sends directly on port 25 from an office or cloud server, move it to an authenticated relay.
- Check that your inbound side accepts mail on port 25 and offers STARTTLS: the Email Health Check reviews your MX, SPF and DMARC records in one pass.
- For low-volume senders such as a self-hosted server, scanner or contact form, iBlockSpam's outbound relay is a smart host with DKIM signing and outbound filtering, with 500 messages per domain per month included.
Frequently asked questions
Is port 587 or 465 more secure?
Neither, if both are set up correctly. RFC 8314 says there is no significant difference in security between STARTTLS on 587 and implicit TLS on 465 when both client and server require TLS before sending. The risk with 587 is a client that continues in plain text if STARTTLS fails, so make sure TLS is required, not optional.
Can I use port 25 to send email from my app?
Usually you shouldn't. Port 25 is meant for server-to-server relay, many ISPs and cloud platforms block it outbound, and most providers want apps to authenticate on 587 or 465. Microsoft 365's SMTP relay connector uses port 25 and authenticates by certificate or static IP instead of a password; Direct Send also uses port 25 but only reaches your own Microsoft 365 mailboxes.
Why does my email client time out on port 25?
A connection that hangs and then times out on port 25 usually means something between you and the server is blocking it, most often your ISP, your firewall or your cloud host. Switch the client to port 587 or 465 with authentication. Those ports are rarely blocked because they're meant for authenticated users.
Can I receive email on port 587 instead of 25?
No. Other mail servers find yours through your MX record, and MX records have no port field. RFC 8314 notes that the MX infrastructure "has no way to specify a port, so port 25 is always used". Your inbound server or filter must accept connections on port 25.
What is port 2525 used for?
Port 2525 isn't registered for email; IANA lists it for an unrelated service. Some email sending services accept submission on it as a fallback for networks that block the standard ports. Use it only if your provider documents it, and with TLS and authentication as you would on 587.
Sources
- RFC 8314: Cleartext Considered Obsolete: Use of TLS for Email Submission and Access
- RFC 6409: Message Submission for Mail
- RFC 5321: Simple Mail Transfer Protocol
- M3AAWG: Port 25 Document Refresh
- Microsoft Learn: Troubleshoot outbound SMTP connectivity problems in Azure
- Google Cloud: Sending email from an instance
- Microsoft Learn: How to set up a multifunction device or application to send email using Microsoft 365
- Google Workspace Admin Help: Send email from a printer, scanner, or app
See how your domain measures up
Run a free Email Health Check: MX, SPF, DKIM, DMARC and transport security in one scan, with the raw records shown. No sign-up.
Keep reading
What is SMTP and how does it deliver email?
How SMTP moves email between servers: the EHLO, MAIL FROM, RCPT TO and DATA dialogue, envelope vs header From, relays, retries and what reply codes mean.
9 min read Email security basicsIs my email encrypted in transit? STARTTLS, MTA-STS and DANE explained
What STARTTLS does for email, why opportunistic TLS can be downgraded, how MTA-STS and DANE enforce it, what Gmail's lock icons mean, and where TLS stops.
9 min read Email security basicsWhat is an MX record?
What an MX record is, how priority values pick the server that gets your mail, why backup MX can bypass a spam filter, and how to check your own records.
8 min read