madebythink / craft-microsoft-365-mail-transport
Microsoft 365 Mail Transport plugin for CraftCMS developed by Think
Package info
github.com/madebythink/craft-microsoft-365-mail-transport
Type:craft-plugin
pkg:composer/madebythink/craft-microsoft-365-mail-transport
v4.0.0
2025-09-29 01:37 UTC
Requires
- php: >=8.2
- craftcms/cms: ^4.0
- guzzlehttp/guzzle: ^7.0
- league/oauth2-client: ^2.7
Requires (Dev)
- craftcms/ecs: dev-main
- craftcms/phpstan: dev-main
This package is not auto-updated.
Last update: 2026-07-07 05:27:50 UTC
README
This plugin allows Craft CMS to send email using the Microsoft Graph API, authenticating with OAuth 2.0.
Requirements
- Craft CMS 5.0+
- PHP 8.0+
- An Azure Active Directory account with permissions to create and manage App Registrations.
- A licensed Microsoft 365 mailbox to send email from.
Installation
- Install with Composer:
composer require madebythink/craft-microsoft-365-mail-transport
- In the Craft Control Panel, go to Settings > Plugins and install the "Microsoft 365 Mail Transport" plugin.
Azure App Registration Setup
You must create an App Registration in Azure AD to get the credentials this plugin needs.
- Log in to the Azure Portal.
- Navigate to Azure Active Directory.
- Go to App registrations and click + New registration.
- Give your application a Name (e.g., "Craft CMS Mailer").
- For Supported account types, select "Accounts in this organizational directory only (Single tenant)".
- Click Register.
Step 1: Get Tenant ID and Client ID
- On the Overview page for your new app registration, copy the Directory (tenant) ID and the Application (client) ID. You will need these for the plugin settings in Craft.
Step 2: Create a Client Secret
- In the app registration menu, go to Certificates & secrets.
- Click + New client secret.
- Give it a description (e.g., "Craft Plugin Secret") and choose an expiry duration.
- Click Add.
- IMMEDIATELY COPY THE "VALUE". This is your Client Secret. It will be hidden after you leave this page.
Step 3: Grant API Permissions
- In the app registration menu, go to API permissions.
- Click + Add a permission.
- Select Microsoft Graph.
- Select Application permissions. (Important: NOT "Delegated permissions").
- In the "Select permissions" search box, type
Mail.Sendand check the box next to Mail.Send. - Click Add permissions.
Step 4: Grant Admin Consent
- Because you added an Application permission, an administrator must grant consent.
- On the API permissions page, click the "Grant admin consent for [Your Directory Name]" button. The status for the
Mail.Sendpermission should change to "Granted".
Plugin Configuration
- In the Craft Control Panel, go to Settings > Email.
- For the Transport Type, select "Microsoft 365 (Graph API)".
- Fill in the settings fields with the values you copied from Azure:
- Tenant ID: Your Directory (tenant) ID.
- Client ID: Your Application (client) ID.
- Client Secret: The secret value you created.
- From Email Address: The email address of the licensed mailbox you want to send emails from (e.g.,
noreply@yourdomain.com).
- Save the settings and use the "Test" utility to send a test email.
It's highly recommended to store your credentials as environment variables in your .env file and reference them in the settings fields (e.g., $M365_CLIENT_ID).