How to Send Email From a GoDaddy PHP Website Through Microsoft 365
Question details
The user needs to configure a PHP website hosted on GoDaddy to send emails using a Microsoft 365 account.

- Product
- Microsoft 365
- Device & OS
- not provided
- Scenario
- Configuring backend PHP code on a GoDaddy website to send outgoing transactional or notification emails through Microsoft 365.
- Observed behavior
- Standard PHP mail functions and basic ini_set configurations fail to send emails because they do not support the required OAuth 2.0, TLS encryption, and strict SMTP authentication policies enforced by Microsoft 365.
Ensure you have administrator access to your Microsoft 365 Admin Center to check SMTP authentication settings or register applications for OAuth 2.0, and access to your GoDaddy hosting control panel.
Use PHPMailer or Symfony Mailer with OAuth 2.0
This is the most secure and recommended method. Using a maintained library with modern authentication ensures compatibility with Microsoft 365's strict security requirements.
Microsoft 365 deprecates basic authentication for exchange online. Utilizing OAuth 2.0 alongside a robust mail library like PHPMailer or Symfony Mailer guarantees secure, uninterrupted email delivery without exposing static passwords.
Log into the Azure portal, navigate to Azure Active Directory > App registrations, and create a new application. Generate a Client ID, Tenant ID, and Client Secret.
Use Composer on your GoDaddy hosting environment to require either PHPMailer or Symfony Mailer (e.g., run 'composer require phpmailer/phpmailer').
In your PHP script, set the host to 'smtp.office365.com', the port to 587, and enable TLS encryption. Supply the OAuth token provider with your Azure AD Client ID, Secret, and Tenant ID instead of a static password.

Use the Microsoft Graph API
Ideal for custom applications that want to bypass standard SMTP protocols and interact directly with Microsoft 365 services via REST API.
Use Authenticated SMTP (If permitted by tenant)
A legacy solution using basic authentication (username and password). Only applicable if your Microsoft 365 tenant still allows SMTP AUTH.
Looking for a Lightweight Alternative to Microsoft Office?
While resolving complex server integrations and developer configurations for Microsoft 365, you might also be searching for a simpler, cost-effective way to manage your local documents. WPS Office is a powerful, free alternative that perfectly handles your daily productivity needs without the heavy subscription fees.
- 1. Download WPS Office: Visit the official WPS website and click the free download button for your operating system.
- 2. Install the Suite: Run the lightweight installer and follow the on-screen instructions to set up the software in minutes.
- 3. Open Your Documents: Launch WPS Office to immediately open, edit, and save your existing Microsoft Word, Excel, and PowerPoint files.

Frequently Asked Questions
Why doesn't the built-in PHP mail() function work with Microsoft 365?
The standard PHP mail() function and basic ini_set configurations cannot handle the modern OAuth 2.0 authentication, TLS encryption, and specific SMTP handshake parameters required by Microsoft 365 to securely route outgoing emails.
What are the correct SMTP settings for Microsoft 365?
The standard SMTP server hostname is smtp.office365.com. The connection requires port 587, TLS encryption enabled, and a valid form of authentication (preferably OAuth 2.0).
How do I safely store my Microsoft 365 email credentials in my GoDaddy website?
You should never store passwords or Azure client secrets directly in your PHP source code. Instead, use secure environment variables (.env files) or keep the configuration files in a directory above your public web root.
Do I need to enable SMTP AUTH for my Microsoft 365 account to send emails?
If you are using legacy basic authentication (username and password), SMTP AUTH must be explicitly enabled for the mailbox in the Microsoft 365 Admin Center. However, using modern OAuth 2.0 or Microsoft Graph API bypasses this requirement.




