logo
search
Send & Receive Issues

How to Send Email From a GoDaddy PHP Website Through Microsoft 365

Algirdas JasaitisAlgirdas Jasaitis Oct 7, 2026 869 views

Question details

The user needs to configure a PHP website hosted on GoDaddy to send emails using a Microsoft 365 account.

How to Send Email From a GoDaddy PHP Website Through Microsoft 365
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.
Before you start

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.

Solution 1Recommended

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.

1
Register your Application in Azure Active Directory

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.

2
Install a Mail Library

Use Composer on your GoDaddy hosting environment to require either PHPMailer or Symfony Mailer (e.g., run 'composer require phpmailer/phpmailer').

3
Configure SMTP Settings and OAuth

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 PHPMailer or Symfony Mailer with OAuth 2.0
Security Best Practice: Never store your Azure Client Secret or SMTP passwords directly in your PHP source code. Always use secure environment variables (.env files) placed outside your public web directory.
Free Microsoft Office alternative

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. 1. Download WPS Office: Visit the official WPS website and click the free download button for your operating system.
  2. 2. Install the Suite: Run the lightweight installer and follow the on-screen instructions to set up the software in minutes.
  3. 3. Open Your Documents: Launch WPS Office to immediately open, edit, and save your existing Microsoft Word, Excel, and PowerPoint files.
Fully compatible with Microsoft Office formats (.docx, .xlsx, .pptx).Free and lightweight with a familiar, easy-to-use user interface.Built-in PDF editing tools and seamless cloud collaboration.No steep learning curves—migrate your daily work instantly.
microsoft office alternative - wps office

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.