Exchange Connection Problems

Fix Office 365 SMTP Connection Timeouts in a PHP Application

Camila MilosovichCamila Milosovich Nov 25, 2026 868 views

Question details

The user needs to resolve an Office 365 SMTP timeout in a PHP web application that sends mail using authenticated submission.

Fix Office 365 SMTP Connection Timeouts in a PHP Application
Product
Microsoft 365 Exchange Online
Device & OS
not provided
Scenario
A PHP application connects to smtp.office365.com on port 587 and may send messages using different From addresses.
Observed behavior
The SMTP connection times out; a command-line test reported that the network was unreachable.
Before you start

Run the connectivity tests from the web server or container that executes PHP, not just from your own computer. Have the application's SMTP settings and access to the server's firewall or hosting controls ready.

Solution 1Recommended

Check Network Access to the Office 365 SMTP Endpoint

Use this first when the connection times out or reports that the network is unreachable.

1
Check DNS resolution

On the web server, run `nslookup smtp.office365.com` or `dig smtp.office365.com` and confirm that the hostname resolves. If it does not, check the server's DNS configuration.

2
Test outbound port 587

Run `nc -vz smtp.office365.com 587` from the same environment as the application. If the connection fails or times out, check outbound firewall rules, routing, and hosting-provider restrictions for TCP port 587.

3
Check IPv4 and IPv6 routes

If both address families are returned, test them separately with `nc -4 -vz smtp.office365.com 587` and `nc -6 -vz smtp.office365.com 587`. A network-unreachable error can indicate a missing route for the affected address family; ask the server administrator to correct it.

4
Test STARTTLS

After TCP connectivity works, run `openssl s_client -starttls smtp -connect smtp.office365.com:587 -servername smtp.office365.com` to check the TLS handshake and certificate verification. Investigate certificate trust or TLS errors reported by the command.

Check Network Access to the Office 365 SMTP Endpoint
Identify the failure stage: A TCP timeout happens before SMTP authentication or sender validation. Fix network access first, then investigate any subsequent authentication or From-address errors.
Free Microsoft Office alternative

Work with Office Files in WPS Office

WPS Office is a free, lightweight alternative for working with documents, spreadsheets, and presentations. Its familiar interface and Office format support make it easy to move existing files, although it does not repair Exchange Online SMTP connections.

Open and edit Microsoft Word, Excel, and PowerPoint formatsUse a familiar interface for everyday Office tasksMove existing Office files into a lightweight productivity suiteKeep working on documents while an administrator resolves the SMTP issue
QA img-9

Frequently Asked Questions

What does a network-unreachable error mean for SMTP?

It usually means the server has no usable route to the selected destination address. Test IPv4 and IPv6 separately from the web server, then check routing and outbound firewall rules.

Should I use SSL or STARTTLS on port 587?

For authenticated submission to smtp.office365.com on port 587, configure STARTTLS with TLS 1.2 or later. Do not select implicit SSL for that port.

Can my application send from a different mailbox?

It may do so if the authenticated account has the appropriate Send As permission for that mailbox. First test with the authenticated mailbox in the From field, then configure and verify permissions for the other address.

Why does SMTP still fail after port 587 is reachable?

Check the TLS handshake, SMTP AUTH settings, supported authentication method, and sender permissions. Look at the application's SMTP error log to determine which stage fails.

Which endpoint does Exchange Online SMTP relay use?

Connector-based SMTP relay normally uses your Microsoft 365 domain's MX endpoint on port 25, not smtp.office365.com on port 587. The connector must identify the sending server by an allowed public IP address or a supported certificate configuration.