Fix Office 365 SMTP Connection Refused on Port 587 in WordPress
Question details
The user needs to connect a WordPress site to Office 365 SMTP through the WP Mail SMTP plugin.

- Product
- Microsoft 365 Exchange Online SMTP and WP Mail SMTP
- Device & OS
- not provided
- Scenario
- A WordPress site is configured to send mail through smtp.office365.com on port 587.
- Observed behavior
- The plugin reports a connection-refused error, and the hosting provider suspects IPv6 or suggests using a direct IP address.
Have your WP Mail SMTP settings and hosting provider details available. If you have server shell access, check whether tools such as nslookup, nc, or OpenSSL are installed.
Check outbound port 587 and Office 365 SMTP settings
Use these checks to identify whether the refusal comes from the network path or an incorrect SMTP configuration.
In WordPress, open WP Mail SMTP > Settings and review the selected mailer's settings. For a manual SMTP configuration, use smtp.office365.com, port 587, and TLS/STARTTLS rather than implicit SSL.
From the hosting server's shell, run nslookup smtp.office365.com to check that the hostname resolves. An IPv4-only server can connect to Office 365; IPv6 support is not required.
From the hosting server, run nc -vz smtp.office365.com 587 if nc is available. If the connection is refused or times out, ask the hosting provider to check outbound SMTP restrictions, firewall rules, and the network path.
If port 587 is reachable, run openssl s_client -starttls smtp -connect smtp.office365.com:587 from the server. Review any TLS errors and ask the hosting provider to check the server's TLS configuration if the handshake fails.
In WordPress, open WP Mail SMTP > Tools > Email Test and send a test message. If the connection succeeds but authentication fails, review the plugin's Microsoft 365 mailer setup and the Exchange Online SMTP authentication policy for the mailbox.

Configure network rules using Microsoft's current endpoint information
Use this approach when a firewall or hosting provider requires destination rules for Microsoft 365.
Document SMTP Troubleshooting in WPS Office
WPS Office is a free, lightweight Microsoft Office alternative with a familiar interface and support for common Office formats, making it easy to move troubleshooting notes and reports between suites. It does not fix Exchange Online SMTP connectivity.

Frequently Asked Questions
Does Office 365 SMTP require IPv6?
No. Office 365 supports IPv4 and IPv6, so an IPv4-only server can connect. Check DNS resolution and outbound access to smtp.office365.com on port 587.
Should I use a Microsoft IP address instead of smtp.office365.com?
Keep smtp.office365.com in the SMTP host field. Microsoft service IP addresses can change; consult the current Office 365 URLs and IP address ranges documentation for network rules.
Which encryption setting should I use for port 587?
In the manual SMTP settings under WP Mail SMTP > Settings, select TLS/STARTTLS for port 587 rather than implicit SSL.
What if port 587 works but the test email still fails?
Check the error shown under WP Mail SMTP > Tools > Email Test. For an authentication error, review the mailer's setup and the Exchange Online SMTP authentication policy for the mailbox.




