paubikas/laravel-msgraph-mailer
Composer 安装命令:
composer require paubikas/laravel-msgraph-mailer
包简介
Laravel mail driver to send emails using Microsoft Graph, supporting both personal accounts as well as work/school accounts (365/Exchange)
README 文档
README
This package makes it easy to send emails from your personal, work or school account using Microsoft's Graph API, allowing you to benefit from HTTP instead of SMTP with Laravel.
Inspired by wapacro/laravel-msgraph-mail and fixed to work with Laravel 12/13
Installation
Install the package using composer:
composer require paubikas/laravel-msgraph-mailer
Add the configuration to your mail.php config file:
'mailers' => [ 'microsoft-graph' => [ 'transport' => 'microsoft-graph', 'tenant' => env('MAIL_MSGRAPH_TENANT', 'common'), 'client' => env('MAIL_MSGRAPH_CLIENT'), 'secret' => env('MAIL_MSGRAPH_SECRET'), 'saveToSentItems' => env('MAIL_MSGRAPH_SAVE_TO_SENT_ITEMS', false) ] // ... ]
Add the configuration to your ENV file:
MAIL_MAILER=microsoft-graph MAIL_MSGRAPH_TENANT= MAIL_MSGRAPH_CLIENT= MAIL_MSGRAPH_SECRET= MAIL_MSGRAPH_SAVE_TO_SENT_ITEMS=false
Valid values for tenant are your tenant identifier (work & school accounts) or common for personal accounts.
Note: This package relies on Laravel's Cache interface for caching access tokens. Make sure to configure it properly, too!
Internal Message Headers and Other Microsoft Graph Custom Headers
To include internal message headers when sending an email via Microsoft Graph, you should use the envelope() function along with the using callback. This allows you to pass custom headers, including internal ones. You can also add other supported headers. For a full list of available headers, refer to the official documentation: Microsoft Graph Message Resource.
Here’s an example of how to add headers:
using: [
function (Email $email) {
$email->getHeaders()->addHeader('isReadReceiptRequested', 'true');
$email->getHeaders()->addHeader('isDeliveryReceiptRequested', 'true');
$email->getHeaders()->addHeader('internetMessageHeassders', json_encode([
'X-Test-ID' => 'TestID',
]));
}
]
Getting the credentials
To get the necessary client ID and secret you'll need to register your application and grant it the required permissions. Head over to the Azure Portal to do so (you don't need to be an Azure user).
Make sure to grant the Mail.Send permission and to generate a secret afterwards (may be hidden during app registration).
Work & School accounts: Granting your app the Mail.Send permission allows you by default to send emails with every valid email address within your company/school. Use an Exchange Online Application Access Policy to restrict which email addresses are valid senders for your application.
paubikas/laravel-msgraph-mailer 适用场景与选型建议
paubikas/laravel-msgraph-mailer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7.02k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2022 年 08 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「mail」 「graph」 「laravel」 「microsoft」 「exchange」 「365」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 paubikas/laravel-msgraph-mailer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 paubikas/laravel-msgraph-mailer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 paubikas/laravel-msgraph-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
统计信息
- 总下载量: 7.02k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-08-04