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 10 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, the exact settings Microsoft 365 and Google Workspace document at the time of writing (November 2026), and a troubleshooting checklist.
Which SMTP port should you use?
Use port 587 or 465 with authentication for anything that logs in to send, and port 25 only between mail servers. 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 | IANA name | Standard | Encryption | Authentication | Use it for |
|---|---|---|---|---|---|
| 25 | smtp | RFC 5321 | Optional STARTTLS | Not normally | Server-to-server delivery to MX hosts |
| 587 | submission | RFC 6409 | STARTTLS (upgrade after connecting) | Required | Apps, devices and mail clients sending through a provider |
| 465 | submissions | RFC 8314 | Implicit TLS (encrypted from the first byte) | Required | Same as 587, where the provider supports it |
| 2525 | ms-v-worlds (not mail) | None | 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 SMTP relay port that mail servers use to deliver mail to each other, and it's the only port used for that. It's the original SMTP port. 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: the port where a mail client, app or device hands a new message to its own provider after logging in. 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.
RFC 6409 doesn't forbid submission on port 25. Section 3.1 says "a site MAY choose to use port 25 for message submission," which is why some providers, Microsoft 365 among them, accept authenticated submission on 25 as well as 587. Port 587 is still the default, and it's far less likely to be blocked by your network.
What is port 465 for?
Port 465 is submission with implicit TLS, and RFC 8314 makes it the preferred submission port. 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: the IANA registry now assigns TCP 465 to "submissions" ("Message Submission over TLS protocol").
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 |
Microsoft 365, High Volume Email (smtp.hve.mx.microsoft) |
587 with TLS; HVE account credentials or OAuth; 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) |
587 with TLS; 25, 465 or 587 without TLS, using IP address authentication |
Google Workspace, restricted Gmail SMTP server (aspmx.l.google.com) |
25, no authentication; Gmail and Google Workspace recipients only |
Sources: Microsoft Learn, Microsoft Learn on HVE, Google Workspace Admin Help and Google's SMTP relay article, at the time of writing (November 2026).
Which SMTP port does Microsoft 365 use?
Microsoft 365 client submission uses smtp.office365.com on port 587 with STARTTLS (TLS 1.2 or 1.3), or port 25 as an alternative; it doesn't support port 465. These are the settings Microsoft Learn documents for a device or app that logs in to a mailbox:
- Server:
smtp.office365.com. Microsoft says to use the DNS name, not an IP address. - Port: 587 (recommended) or 25. "If your device or application recommends or defaults to TCP port 465, it doesn't support the required versions of TLS" for this service.
- Encryption: TLS/StartTLS enabled, TLS 1.3 or TLS 1.2.
- Credentials: the sign-in of a licensed mailbox, ideally through OAuth. Microsoft says SMTP AUTH "is disabled for organizations created after January 2020" but can be enabled per mailbox.
- Send As: if the app sends as a different address, the sign-in account needs Send As permission, or the message bounces with 5.7.60.
The password part is changing. In its January 27, 2026 post, Updated Exchange Online SMTP AUTH Basic Authentication Deprecation Timeline, Microsoft says SMTP AUTH Basic authentication "remains unchanged" through December 2026. At the end of December 2026 it "will be disabled by default for existing tenants," though admins "will still be able to enable it if needed." For new tenants created after December 2026 it "will be unavailable by default," so they must use OAuth. Microsoft will announce the final removal date in the second half of 2027. Earlier dates you may have read, such as September 2025 or March to April 2026, were replaced by this timeline. Our guide to the SMTP AUTH Basic auth retirement covers how to find affected senders and move them.
The port doesn't change for either alternative: a relay connector uses port 25 to your MX endpoint, and High Volume Email uses port 587 but only delivers inside your tenant. Our scan to email guide compares the options for printers and line-of-business apps, and email sending limits lists how much each method can send.
Which SMTP port does Gmail or Google Workspace use?
Gmail's SMTP server, smtp.gmail.com, uses port 465 for SSL (implicit TLS) or port 587 for TLS (STARTTLS), and Google Workspace's SMTP relay service, smtp-relay.gmail.com, uses port 587 with TLS. Google's printer, scanner and app page adds a sign-in rule that matters more than the port: "Starting May 1, 2025, Google Workspace accounts no longer support less secure apps, third-party apps, or devices that ask you to sign in" with only a username and password. A device needs OAuth, or an app password when 2-Step Verification is on, to use smtp.gmail.com.
The SMTP relay avoids per-user passwords by authenticating your devices by IP address or with SMTP AUTH over TLS. For full settings and app password steps, see Gmail SMTP server settings and Google Workspace SMTP relay setup. For a website, read WordPress SMTP setup with SPF and DKIM.
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. For provider-by-provider details and how to request removal, see port 25 blocked by cloud hosts and ISPs. 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. For a full command-line session, see how to test an SMTP server with Telnet and OpenSSL. - 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. Security defaults in Microsoft Entra ID also block Basic authentication, and from the end of December 2026 Basic auth for SMTP AUTH is off by default in existing tenants. In Google Workspace, a password-only sign-in to
smtp.gmail.comfails unless the device uses OAuth or an app password. - 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.
- List every device that signs in to Microsoft 365 with a password and move it to OAuth, a relay connector or HVE before Basic auth for SMTP AUTH is disabled by default at the end of December 2026.
- 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.
Is port 465 deprecated for sending email?
No. Port 465 was briefly registered for SMTP over TLS and then revoked, which is why older articles call it deprecated. RFC 8314 registered it again in 2018 as the "submissions" port and recommends implicit TLS on 465 in preference to STARTTLS. Some providers, including Microsoft 365 client submission, still don't support it.
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
- Microsoft Tech Community: Updated Exchange Online SMTP AUTH Basic Authentication Deprecation Timeline (January 2026)
- 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 basicsPort 25 blocked: why cloud hosts and ISPs block SMTP, and what to do
Why AWS, Azure, Google Cloud, DigitalOcean, Hetzner and home ISPs block outbound port 25, how to test for it, how to request removal, and what to use instead.
10 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