Exchange Connection Problems

Fix SMTP Connection Refused Error 111 in PHPMailer (Microsoft 365)

Olivia MillerOlivia Miller Nov 3, 2026 870 views

Question details

The user is encountering an 'SMTP ERROR: Failed to connect to server: Connection refused (111)' message when attempting to send emails using PHPMailer through Microsoft 365 Exchange.

How to Fix SMTP Connection Refused Error 111 in PHPMailer
Product
PHPMailer and Microsoft 365 Exchange
Device & OS
not provided
Scenario
Configuring a web application with PHPMailer to send outbound emails via Microsoft 365 Exchange servers.
Observed behavior
The connection to the Microsoft 365 SMTP server fails, resulting in a Connection Refused (111) error, preventing the web application from sending emails.
Before you start

Ensure you have administrator access to your Microsoft 365 admin center and verify with your hosting provider that standard outbound email ports are unblocked on your web server.

Solution 1Recommended

Enable Authenticated SMTP in Microsoft 365 Admin Center

Microsoft 365 disables SMTP authentication by default for security, which blocks client submissions from tools like PHPMailer. Enabling this for the specific email account often resolves the issue.

By default, Exchange Online disables Basic Authentication and Authenticated SMTP to protect user accounts. If your application relies on SMTP client submission, you must explicitly enable Authenticated SMTP for the mailbox used by PHPMailer.

1
Access Active Users

Log in to the Microsoft 365 admin center. Navigate to the left menu, click on 'Users', and then select 'Active users'.

2
Select the Mailbox User

Find and click on the specific user account that PHPMailer is using to authenticate and send emails.

3
Manage Email Apps

In the user's details pane that slides out, click on the 'Mail' tab. Under the Email apps section, click on 'Manage email apps'.

4
Enable Authenticated SMTP

Check the box next to 'Authenticated SMTP' to enable it for this account, then click 'Save changes'.

Enable Authenticated SMTP in Microsoft 365 Admin Center
Propagation Time: It can take up to 30 minutes for the Authenticated SMTP setting changes to take effect across Exchange Online.
Free Microsoft Office alternative

Looking for a Lightweight Alternative to Microsoft Office?

If managing expensive Microsoft 365 subscriptions and complex Exchange configurations is slowing your business down, consider switching to WPS Office. It provides a free, highly compatible suite for standard document management without the overhead.

  1. 1. Download WPS Office: Visit the official WPS website and download the free installation package for your operating system.
  2. 2. Install the Suite: Run the installer and follow the simple on-screen instructions to set up WPS Office on your device.
  3. 3. Open Office Files: Instantly open, edit, and save your existing Word, Excel, and PowerPoint files without formatting issues.
Fully compatible with standard Microsoft Office formats (Word, Excel, PowerPoint) and email attachments.Free and lightweight alternative to heavy Microsoft 365 subscriptions.Familiar, clean user interface requiring zero learning curve for switching.Seamlessly handle, edit, and convert documents attached to your automated emails.
microsoft office alternative - wps office

Frequently Asked Questions

Does Error 111 mean my MX records are incorrectly configured?

No. MX records are used by external mail servers to locate your server for incoming mail. The Connection Refused (111) error indicates an outbound connectivity issue, meaning your web server cannot reach the outgoing SMTP host due to network blocks or configuration errors.

Which SMTP host and port should I use for Microsoft 365 in PHPMailer?

You should use 'smtp.office365.com' as the host, port 587, and enable STARTTLS encryption. Ensure that your account has Authenticated SMTP enabled in the Microsoft 365 Admin Center.

How can I tell if my web hosting provider is blocking outbound SMTP connections?

You can test outbound connectivity by logging into your web server via SSH and running the command 'telnet smtp.office365.com 587'. If the connection fails or hangs, your hosting provider's firewall is likely blocking the outbound traffic, and you will need to ask them to open port 587.