How to Fix Microsoft 365 SMTP Authentication Errors in PHP Applications
Question details
The user needs to configure a PHP application to successfully authenticate and send emails using a Microsoft 365 business mailbox via SMTP.

- 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.
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.
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.
Navigate to outlook.office.com and log in using the exact email address and password configured in your PHP application.
Click 'New message' and send a test email to another address to verify that the account is active and has outbound sending permissions.
Log in to the Microsoft 365 Admin Center, go to Active Users, and ensure the account's sign-in status is not blocked.

Enforce TLS 1.2 in Your PHP Application
Microsoft 365 requires TLS 1.2 or higher for SMTP client submission. Legacy versions like TLS 1.0 or 1.1 will result in authentication failures.
Enable Authenticated SMTP for the User Account
Resolve SMTP errors such as 535 5.7.3 or 5.7.57 by enabling basic authentication for SMTP on the specific mailbox.
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. Download the Installer: Visit the official WPS Office website and click the free download button.
- 2. Install the Software: Run the lightweight installer and follow the on-screen instructions to complete the setup in minutes.
- 3. Open and Edit: Launch WPS Office and immediately open your existing Microsoft Office documents without any formatting loss.

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.




