5 Key Points About Office 365 SMTP Ports for Secure Email Delivery
Configuring email for applications, scanners, and printers requires a precise understanding of Microsoft 365 (formerly Office 365) connection settings. The primary SMTP ports used are Port 587 for authenticated client submission and Port 25 for SMTP relay or d...
Configuring email for applications, scanners, and printers requires a precise understanding of Microsoft 365 (formerly Office 365) connection settings. The primary SMTP ports used are Port 587 for authenticated client submission and Port 25 for SMTP relay or direct send. Choosing the correct port depends on your device’s capabilities, the need for encryption, and whether you are sending mail to external recipients or just internal users.
Contents
Understanding the Role of SMTP Ports in Microsoft 365
SMTP (Simple Mail Transfer Protocol) is the engine that drives email transmission across the internet. In the ecosystem of Microsoft 365, SMTP acts as the bridge between your local devices—such as multi-function printers (MFPs), line-of-business (LOB) applications, and specialized software—and the Exchange Online servers. As we navigate the technical landscape of 2026, the security requirements surrounding these ports have become more stringent to combat sophisticated phishing and spoofing attacks.
The "port" is essentially a virtual communication channel. Different ports represent different methods of handling data, specifically regarding how security handshakes are performed. Using the wrong port often results in "Authentication Failed" errors or "Connection Timed Out" messages. To ensure reliable mail flow, administrators must align their hardware and software configurations with Microsoft’s modern security protocols, specifically focusing on Transport Layer Security (TLS) and modern authentication mechanisms.
1. Port 587: The Industry Standard for Authenticated Client Submission
Port 587 is the recommended configuration for almost all modern applications and devices that need to send mail through a specific Microsoft 365 mailbox. This method is technically known as SMTP AUTH client submission. When you use Port 587, your device connects to the server and immediately requests an upgraded, secure connection using the STARTTLS command.
Why Port 587 is Preferred
Unlike the legacy Port 25, Port 587 was specifically designed for "message submission" rather than "message relay." In 2026, nearly all Internet Service Providers (ISPs) and cloud hosting environments (like Azure or AWS) allow outbound traffic on Port 587 while blocking Port 25 to prevent spam. This makes 587 the most compatible choice for remote offices or cloud-hosted applications.
Security and Encryption Requirements
Using Port 587 requires explicit encryption. Microsoft 365 demands TLS 1.2 or TLS 1.3 for these connections. If your device is several years old and does not support at least TLS 1.2, it will fail to connect. Furthermore, this port requires valid credentials (a username and password) for a licensed Microsoft 365 mailbox. In 2026, while Basic Authentication for many protocols has been retired, SMTP AUTH remains a supported (though strictly controlled) method, often requiring the use of App Passwords or specific tenant-level permissions to remain functional.
2. Port 25: The Legacy Gateway and Its Modern Limitations
Port 25 is the original SMTP port, established decades ago for server-to-server communication. In the context of Microsoft 365, Port 25 is primarily used for two specific scenarios: Direct Send and Microsoft 365 SMTP Relay.
Direct Send Configuration
With Direct Send, your device sends mail directly to the Microsoft 365 MX (Mail Exchanger) endpoint. This method does not require a licensed mailbox, which saves on subscription costs for high-volume automated alerting. However, it comes with a major caveat: you can only send emails to recipients within your own Microsoft 365 organization. Port 25 is the standard here because the device is acting like any other mail server on the internet delivering mail to your domain.
SMTP Relay via Connectors
For organizations that need to send to external recipients without using a specific mailbox's credentials, an SMTP Relay is configured using a "Connector" in the Exchange Admin Center. This connector authorizes your device’s public IP address. While this method uses Port 25, it is often difficult to implement in 2026 because most modern network security policies block outbound Port 25 to mitigate the risk of botnets sending spam. If you must use Port 25, you may need to coordinate with your ISP or configure a specialized outbound rule in your firewall.
3. The Shift from Port 465 and Implicit SSL/TLS
A common point of confusion for IT administrators is Port 465. Historically, Port 465 was used for "Implicit SSL," where the connection is encrypted before any SMTP commands are even sent. While some major email providers (like Gmail) still support Port 465, Microsoft 365 does not officially support Port 465 for SMTP client submission.
Explicit vs. Implicit Encryption
The difference lies in how the security handshake occurs.
- Port 587 (Explicit TLS): The device starts an unencrypted conversation and then says "STARTTLS" to switch to an encrypted channel.
- Port 465 (Implicit SSL): The device expects an encrypted channel to be established the moment the connection starts.
If you attempt to use Port 465 with the Microsoft 365 SMTP endpoint (smtp.office365.com), the connection will typically hang and eventually time out because the server is waiting for a command while the client is waiting for a security certificate. For any configuration in 2026, you should avoid Port 465 and stick to the documented standards provided by Microsoft.
4. SMTP Authentication and the Move Toward Modern Auth
While the "port" defines the channel, the "authentication" defines the permission. For years, SMTP ports were paired with Basic Authentication (simple username and password). However, as of 2026, Microsoft has significantly tightened the rules around how these ports are accessed.
Managing SMTP AUTH
Even if you have the correct port (587), your connection may fail if SMTP AUTH is disabled at the tenant level. Microsoft disables this by default for new tenants to enhance security. Administrators must manually enable it for specific mailboxes that require it. This is done through the Microsoft 365 Admin Center or via PowerShell using the Set-CASMailbox cmdlet.
The Role of OAuth2
For developers building custom applications, the use of Port 587 should ideally be paired with OAuth2 authentication rather than a static password. This involves using an Access Token granted by Azure Active Directory (now Microsoft Entra ID). This approach is significantly more secure because it doesn't require storing a permanent password in the application code and allows for more granular control over what the application can do within the mailbox.
5. Direct Send vs. SMTP Relay: Choosing the Right Configuration
Deciding which port to use depends entirely on your specific business requirements. Most small businesses will find Port 587 sufficient, while larger enterprises with high-volume scanning needs often look toward Port 25 solutions.
| Feature | SMTP AUTH (Port 587) | Direct Send (Port 25) | Microsoft 365 Relay (Port 25) |
|---|---|---|---|
| Recipients | Internal & External | Internal Only | Internal & External |
| Authentication | Mailbox Credentials | None (IP-based) | None (Connector-based) |
| License Needed | Yes (per mailbox) | No | No (usually) |
| Encryption | STARTTLS (Required) | Optional (but recommended) | Optional (but recommended) |
| ISP Blocking | Rarely blocked | Commonly blocked | Commonly blocked |
When to Use Port 587
Use this if you need to send mail to customers, vendors, or any address outside your company, and your device supports entering a username and password. This is the most "set it and forget it" method for low-to-medium volume needs.
When to Use Port 25 (Direct Send)
Use this for internal alerts, such as a server notifying an IT team of a backup failure. Since it doesn't require a license, it is cost-effective, provided your network allows Port 25 traffic.
When to Use Port 25 (Relay)
Use this for high-volume applications or older devices that cannot use Port 587. You must have a static public IP address for this to function, as the Microsoft 365 Connector uses your IP as your "identity."
Troubleshooting and Security Best Practices for SMTP in 2026
If you have configured the ports correctly but mail is still not flowing, the issue usually lies in the network layer or the security policy. In 2026, security defaults often override manual settings.
- Check the SPF Record: If you are using Port 25 (Direct Send or Relay), your domain's SPF (Sender Policy Framework) record must be updated to include the IP address of your sending device or the
include:spf.protection.outlook.comdirective. Failure to do this will result in your emails being marked as spam or rejected entirely. - Verify Firewall Outbound Rules: Many corporate firewalls have "Egress Filtering" enabled. You must explicitly allow your device to talk to the internet over Port 587 or Port 25.
- Test via PowerShell: Before blaming the device, use a PowerShell script on a computer in the same network to test the connection. The
Send-MailMessagecmdlet (though deprecated, still useful for testing) or the newerSend-MgUserMailvia Graph API can help isolate whether the problem is the network or the device configuration. - TLS Version Mismatch: Ensure the device is not trying to use TLS 1.0 or 1.1. Microsoft 365 has completely deprecated these versions. If your device cannot be upgraded to TLS 1.2, you may need an "SMTP Gateway" or "Email Relay" software running on a local server to act as a middleman.
- Multi-Factor Authentication (MFA): If MFA is enabled on the mailbox you are using for Port 587, a standard password will not work. You must use an App Password, or better yet, exclude that specific "service account" from MFA policies using Conditional Access (while restricting its login to specific trusted IPs for security).
Practical Recommendation for 2026 Deployment
For the vast majority of users, the most reliable and secure path is to standardize on Port 587 using TLS 1.3 and SMTP AUTH. If you are managing a large fleet of legacy devices that do not support modern encryption, do not attempt to force them to connect directly to Microsoft 365. Instead, implement a local SMTP relay server (like IIS SMTP or Postfix). This local server can accept unencrypted traffic from your legacy devices on Port 25 and then "upgrade" that traffic to a secure, authenticated Port 587 connection to Microsoft 365. This hub-and-spoke model simplifies management and ensures that your internal network remains compatible with the ever-evolving security requirements of the cloud.
Related Frequently Asked Questions
Why does my printer fail to send email on Port 587 even with the correct password?
The most common reason is that SMTP AUTH is disabled for that specific mailbox or the entire tenant. By default, Microsoft disables this protocol for security. You must enable it via the Microsoft 365 Admin Center under the mailbox's "Email apps" settings or via PowerShell. Additionally, ensure the printer supports TLS 1.2 or higher.
Can I use Port 25 without a static IP address?
Using Port 25 for a "Connector-based Relay" requires a static IP because Microsoft uses that IP to verify your identity. If you have a dynamic IP, you cannot use the Relay method. However, you can sometimes use "Direct Send" (for internal mail only), though many dynamic IP ranges are blacklisted by Microsoft to prevent home-user spam.
Is Port 465 ever going to be supported by Microsoft 365?
As of 2026, there are no indications that Microsoft will support Port 465 for standard SMTP client submission. Microsoft remains committed to the STARTTLS standard on Port 587. If your software only offers Port 465, you will likely need to use an intermediary relay service or a third-party email gateway.
What is the maximum email size allowed through these ports?
Microsoft 365 generally allows messages up to 35 MB when sent via SMTP. However, keep in mind that binary attachments grow by about 33% when encoded for email (Base64), so a 25 MB file is often the practical limit for a single message.
How do I fix the "5.7.57 Client was not authenticated to send anonymous mail" error?
This error usually occurs on Port 587 when the device attempts to send mail before the STARTTLS command has been successfully negotiated or when the credentials provided are incorrect. Ensure that your device is configured to "Use SSL/TLS" or "Use STARTTLS" and that the "Authenticating User" matches the "From" address of the email.