Download the PHP package delaneydev/microsoftgraph-365-mail without Composer
On this page you can find all versions of the php package delaneydev/microsoftgraph-365-mail. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download delaneydev/microsoftgraph-365-mail
More information about delaneydev/microsoftgraph-365-mail
Files in delaneydev/microsoftgraph-365-mail
Package microsoftgraph-365-mail
Short Description Laravel package for Microsoft graph (Microsoft 365). Manage mail, OneDrive, Teams, Excel, Calendars and Contacts with ease
License MIT
Homepage https://github.com/lloadout/microsoftgraph
Informations about the package microsoftgraph-365-mail
Laravel Microsoft Graph (DelaneyDev Fork) Native Laravel Microsoft Mail driver
What this package does
This package is a Laravel mail driver for Microsoft 365 that sends email via Microsoft Graph (OAuth2).
It’s perfect for:
- No-reply and single mailbox sending (e.g.,
[email protected]) — Single-User Mode ✅ - Classic per-user OAuth sign-in (session-scoped tokens) — Session Mode ✅
This is a fork of
lloadout/microsoftgraph.
DelaneyDev adds Single-User Mode (database-stored token; no session required) while still supporting the original Session Mode.
Quick Start (TL;DR)
1) Install & Publish + migrate
-
Create Azure App (delegated Mail.Send) and put IDs/secrets in
.env(see below) -
Connect once at
/microsoft/connectwhile signed in as the sending mailbox (e.g.,noreply@...) - Use like normal:
1) Azure App — Create and Grant Delegated Mail.Send (don’t change anything else)
- Azure Portal → Azure Active Directory → App registrations → New registration
- Name:
Laravel Microsoft Graph Mailer - Supported account types: your tenant only (or multi-tenant if required)
-
Redirect URI (Web):
- Register
Copy credentials into .env:
-
From Overview:
- Application (client) ID →
MS_CLIENT_ID - Directory (tenant) ID →
MS_TENANT_ID(orcommonif multi-tenant)
- Application (client) ID →
-
From Certificates & secrets:
- New client secret → copy Value →
MS_CLIENT_SECRET
- New client secret → copy Value →
Grant permissions:
-
API permissions → Add a permission → Microsoft Graph → Delegated permissions → add:
- Click Add permissions and Grant admin consent.
2) Configure .env
Set these for both modes. (Choose mode in the next section.)
3) Choose a Mode
A) Single-User Mode (Recommended for no-reply & single mailbox)
What it is: Your app always sends as one mailbox (e.g., [email protected]).
Tokens are stored in the database (encrypted), not in the session. No per-request user login required.
Enable in .env:
Listen for the OAuth callback and store tokens (once):
Add to AppServiceProvider or EventServiceProvider:
Connect once as the sending mailbox:
Accept consent. The token is saved and will be reused automatically.
After this, you can send mail without any user sessions:
B) Session Mode (Upstream behaviour; per-user tokens)
What it is: Each signed-in user authenticates with Microsoft; tokens are stored in session and used per request.
Enable in .env:
Routes:
- Consent redirect:
https://your-domain.com/microsoft/connect - Callback (must match Azure Redirect URI):
https://your-domain.com/microsoft/callback
Put access data in the session after callback (example listener):
The package looks for
session('microsoftgraph-access-data')when connecting.
4) Sending Email (same in both modes)
Required API permission: Mail.Send (Delegated)
.env:
Examples:
5) Package Capabilities (Beyond Mail)
This package wraps Microsoft Graph endpoints for:
- OneDrive Storage (Laravel Storage driver)
- Teams (send messages, list teams/channels)
- Excel (read/write cell ranges)
- Calendars
- Contacts
- Reading & handling Mail
You only need Mail.Send to send mail. Other features require additional permissions (see below).
Storage usage (OneDrive)
Permission: Files.ReadWrite.All
.env:
Use the onedrive disk like any Laravel filesystem disk:
Teams usage
Permission: Chat.ReadWrite
(Extra examples require Group.Read.All, Chat.Read.All, ChannelMessage.Read.All, ChannelMessage.Send)
Excel usage
Permission: Files.ReadWrite.All
Calendar usage
Permission: Calendars.ReadWrite
Contacts usage
Permission: Contacts.ReadWrite
Reading and handling mail
Permissions: Mail.Read, Mail.ReadWrite, Mail.ReadBasic
Available methods
Differences: DelaneyDev Fork vs Upstream
| Topic | DelaneyDev (this fork) | Upstream (lloadout/microsoftgraph) |
|---|---|---|
| Primary goal | Single-User Mode for no-reply/single mailbox sending | Session-based per-user OAuth |
| Token storage | Database (encrypted) via model/migration | Session (microsoftgraph-access-data) |
| Sessions needed to send mail | No (after initial connect) | Yes (user must have session token) |
| Best for | System emails, cron, queues, workers | User-initiated emails on behalf of each user |
| Session Mode | Still supported | N/A (original behavior) |
You can enable either mode via .env.
Troubleshooting
- **Queue workers restarted after changing
.env -
**Clear app cache/Redis if tokens were encrypted with an old key
-
403 / insufficient permissions Confirm Mail.Send (Delegated) is added and admin consent granted in Azure.
- Redirect URI mismatch
The Azure Redirect URI must exactly match
MS_REDIRECT_URL.
Testing
Changelog
See CHANGELOG.
Contributing
See CONTRIBUTING.
Security Vulnerabilities
Please review our security policy.
Credits
- Fork base: Dieter Coopman
- DelaneyDev additions: Single-User Mode + docs
- All Contributors
License
MIT — see LICENSE.
All versions of microsoftgraph-365-mail with dependencies
ext-fileinfo Version *
illuminate/contracts Version ^9|^10.0|^11.0|^12.0
microsoft/microsoft-graph Version ^1.89
socialiteproviders/microsoft Version ^4.2
spatie/laravel-package-tools Version ^1.14.0