logo
search
Exchange Connection Problems

How to Fix Microsoft 365 SMTP Authentication Errors in PHP Applications

Algirdas JasaitisAlgirdas Jasaitis Oct 22, 2026 868 views

Question details

The user needs to configure a PHP application to successfully authenticate and send emails using a Microsoft 365 business mailbox via SMTP.

How to Fix Microsoft 365 SMTP Authentication Errors in PHP Applications
Product
Microsoft 365
Device & OS
not provided
Scenario
Setting up SMTP email delivery in a PHP web application using Microsoft 365 business email credentials.
Observed behavior
The PHP application fails to authenticate with the Microsoft 365 SMTP server despite using correct credentials, even though the same code works flawlessly with Google SMTP.
Before you start

Ensure that your Microsoft 365 business subscription includes Exchange Online and that the specific user account has an active mailbox assigned and is permitted to send mail.

Solution 1Recommended

Verify Mailbox Status and Web Login

Confirming the mailbox is active and credentials are correct is the first essential step in troubleshooting SMTP failures.

Often, SMTP authentication fails simply because the account is locked, the password has expired, or the mailbox has not been fully provisioned in Exchange Online.

1
Sign in to Outlook on the web

Navigate to outlook.office.com and log in using the exact email address and password configured in your PHP application.

2
Send a manual test email

Click 'New message' and send a test email to another address to verify that the account is active and has outbound sending permissions.

3
Check Microsoft 365 Admin Center

Log in to the Microsoft 365 Admin Center, go to Active Users, and ensure the account's sign-in status is not blocked.

Verify Mailbox Status and Web Login
Password Expiration: If you are prompted to change your password during the web login, complete the update and then apply the new password to your PHP configuration.
Free Microsoft Office alternative

Boost Your Development Workflow with WPS Office

While troubleshooting server connections and coding issues, you need reliable tools to document your infrastructure and application setups. WPS Office is a lightweight, free alternative to Microsoft Office that ensures you can manage your technical documentation without expensive subscriptions.

  1. 1. Download the Installer: Visit the official WPS Office website and click the free download button.
  2. 2. Install the Software: Run the lightweight installer and follow the on-screen instructions to complete the setup in minutes.
  3. 3. Open and Edit: Launch WPS Office and immediately open your existing Microsoft Office documents without any formatting loss.
Fully compatible with Microsoft Word, Excel, and PowerPoint formats (.docx, .xlsx, .pptx)Lightweight and fast to launch, perfect for developers multitasking on heavily loaded machinesCompletely free core features with a familiar, easy-to-use tabbed interfaceBuilt-in PDF editing tools for compiling and sharing technical reports
QA img-9

Frequently Asked Questions

What does SMTP error 535 5.7.139 mean in Microsoft 365?

This error typically indicates that the account has Multi-Factor Authentication (MFA) or Azure Security Defaults enabled, which blocks legacy basic SMTP authentication. You will need to generate an App Password or disable security defaults (not recommended) to send emails via SMTP.

Can I use port 465 for Microsoft 365 SMTP?

No, Microsoft 365 SMTP client submission strictly requires port 587 along with STARTTLS encryption. Using port 465 with implicit SSL is not supported for standard Office 365 SMTP configurations.

Why does my PHP application work perfectly with Gmail SMTP but fail with Microsoft 365?

Google and Microsoft maintain different security baselines and connection requirements. Microsoft 365 strictly enforces TLS 1.2+ and often disables 'Authenticated SMTP' by default at the tenant level. Your Gmail setup may be relying on legacy 'less secure app' settings or a previously configured App Password.