codewrap/laravel-microsoft-graph-mailer
Composer 安装命令:
composer require codewrap/laravel-microsoft-graph-mailer
包简介
Laravel mail driver for Microsoft Graph API.
README 文档
README
A Laravel mail driver that sends email via the Microsoft Graph API using OAuth2 client credentials. Zero external dependencies beyond Laravel itself.
Requirements
- PHP 8.2+
- Laravel 11, 12, or 13
- An Azure AD / Entra ID app registration with
Mail.Sendapplication permission
Installation
composer require codewrap/laravel-microsoft-graph-mailer
Azure AD Setup
- Go to Azure Portal > App registrations > New registration
- Name your app (e.g. "My App Mailer"), select Single tenant
- Go to API permissions > Add permission > Microsoft Graph > Application permissions > Mail.Send > Grant admin consent
- Go to Certificates & secrets > New client secret — copy the secret value
- From the Overview page, copy the Application (client) ID and Directory (tenant) ID
Restrict Sender Addresses (Recommended)
By default, Mail.Send allows sending as any mailbox in your tenant. To restrict which mailboxes the app can send from, configure an Application Access Policy in Exchange Online:
New-ApplicationAccessPolicy -AppId <client-id> -PolicyScopeGroupId <mail-enabled-security-group> -AccessRight RestrictAccess
Configuration
Add the mailer to config/mail.php:
'mailers' => [ 'microsoft-graph' => [ 'transport' => 'microsoft-graph', 'tenant' => env('MAIL_MSGRAPH_TENANT'), 'client' => env('MAIL_MSGRAPH_CLIENT'), 'secret' => env('MAIL_MSGRAPH_SECRET'), 'save_to_sent_items' => env('MAIL_MSGRAPH_SAVE_TO_SENT', true), ], ],
Add to your .env:
MAIL_MAILER=microsoft-graph
MAIL_MSGRAPH_TENANT=your-tenant-id
MAIL_MSGRAPH_CLIENT=your-client-id
MAIL_MSGRAPH_SECRET=your-client-secret
MAIL_FROM_ADDRESS=noreply@yourdomain.com
MAIL_FROM_NAME="Your App"
The MAIL_FROM_ADDRESS must be a valid mailbox in your Microsoft 365 tenant.
Usage
Once configured as the default mailer, all Mail::send() / Mail::to() calls use Microsoft Graph automatically. No code changes needed.
Limitations
- 3 MB attachment limit — Direct file attachments in
sendMailare limited to 3 MB. Attachments between 3-150 MB require a draft + upload session flow (not yet supported). X-Message-ID— Graph'ssendMailreturns no message ID. The driver generates a local correlation UUID, not an Exchange message ID.
National Clouds
For national cloud deployments (US Gov, China), override the API endpoints in your .env:
MSGRAPH_API_BASE_URL=https://graph.microsoft.us/v1.0
MSGRAPH_AUTH_URL=https://login.microsoftonline.us
License
MIT
codewrap/laravel-microsoft-graph-mailer 适用场景与选型建议
codewrap/laravel-microsoft-graph-mailer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 31 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 06 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「mail」 「graph」 「laravel」 「microsoft」 「exchange」 「365」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 codewrap/laravel-microsoft-graph-mailer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 codewrap/laravel-microsoft-graph-mailer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 codewrap/laravel-microsoft-graph-mailer 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Netgen Open Graph Bundle is an Ibexa Platform bundle that allows simple integration with Open Graph protocol.
A tool for scraping URL resources (oEmbed, OpenGraph, Twitter cards, JSON-LD)
Courier offers a convenient and painless solution for creating emails tailored for your Kirby website.
Mail libraries used by Zimbra Api
Email+ extends Kirby's email capabilities by adding support for multiple email services using the same Kirby email API.
Neo4j-PHP-Client is the most advanced PHP Client for Neo4j
统计信息
- 总下载量: 31
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 43
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-06-09