datascaled/laravel-m365-mailer
最新稳定版本:v0.1.1
Composer 安装命令:
composer require datascaled/laravel-m365-mailer
包简介
Laravel mail transport driver for Microsoft 365 / Microsoft Graph with optional GDPR-conscious logging.
README 文档
README
A Laravel mail transport driver for Microsoft 365 / Microsoft Graph with optional GDPR-conscious database logging.
Features
- Full Laravel mailer transport (
transport: m365) for Mailables, Notifications, and queued mails. - Client-credentials flow (
tenant_id,client_id,client_secret). - Optional DB-backed message status history (
queued,sending,sent,failed). - GDPR-oriented defaults: recipient masking + hashing; plaintext recipient storage is opt-in.
- Built-in retention cleanup command:
m365-mail:prune.
Requirements
- PHP 8.3+
- Laravel 11 or 12
Installation
composer require datascaled/laravel-m365-mailer
Quick Start (No DB Logging)
- Configure an
m365mailer inconfig/mail.php.
'mailers' => [ // ... 'm365' => [ 'transport' => 'm365', 'tenant_id' => env('M365_TENANT_ID'), 'client_id' => env('M365_CLIENT_ID'), 'client_secret' => env('M365_CLIENT_SECRET'), 'timeout' => env('M365_MAIL_TIMEOUT', 15), ], ],
- Use it as default mailer or explicitly when sending:
Mail::mailer('m365')->to('user@example.com')->send(new WelcomeMail());
With default config, package logging is disabled and no package-specific DB writes are made.
Advanced Setup (Enable DB Logging)
- Publish package config and migrations:
php artisan vendor:publish --tag="m365-mailer-config" php artisan vendor:publish --tag="m365-mailer-migrations" php artisan migrate
- Enable logging in
config/m365-mailer.phpor.env:
M365_MAIL_LOGGING_ENABLED=true M365_MAIL_LOGGING_REQUIRE_DATABASE=true M365_MAIL_LOGGING_RETENTION_DAYS=30 M365_MAIL_LOGGING_STORE_RECIPIENTS_PLAINTEXT=false
Configuration Reference
config/m365-mailer.php contains:
timeoutsave_to_sent_itemscache_storelogging.enabledlogging.retention_dayslogging.store_recipients_plaintextlogging.require_databaselogging.recipient_hash_key
Per-mailer credentials remain in config/mail.php under mail.mailers.m365.
The sender is always taken from mail.from.address (MAIL_FROM_ADDRESS).
Logging Behavior
logging.enabled = false: package performs no DB logging.logging.enabled = true+require_database = true: missing tables cause a hard fail before sending.- If Graph accepts the message but post-send DB logging fails, sending is not rethrown (prevents duplicate deliveries on queue retry).
Retention / Pruning
Delete old log data:
php artisan m365-mail:prune
Override retention window:
php artisan m365-mail:prune --days=14
Testing
composer test
License
MIT
统计信息
- 总下载量: 13
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-03-31