PHPackages                             datascaled/laravel-m365-mailer - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Mail &amp; Notifications](/categories/mail)
4. /
5. datascaled/laravel-m365-mailer

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

datascaled/laravel-m365-mailer
==============================

Laravel mail transport driver for Microsoft 365 / Microsoft Graph with optional GDPR-conscious logging.

v0.1.1(3mo ago)133↓79.8%MITPHPPHP ^8.3CI passing

Since Mar 31Pushed 3mo agoCompare

[ Source](https://github.com/datascaled/laravel-m365-mailer)[ Packagist](https://packagist.org/packages/datascaled/laravel-m365-mailer)[ Docs](https://github.com/datascaled/laravel-m365-mailer)[ RSS](/packages/datascaled-laravel-m365-mailer/feed)WikiDiscussions main Synced 4w ago

READMEChangelogDependencies (15)Versions (3)Used By (0)

Laravel M365 Mailer
===================

[](#laravel-m365-mailer)

A Laravel mail transport driver for Microsoft 365 / Microsoft Graph with optional GDPR-conscious database logging.

Features
--------

[](#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
------------

[](#requirements)

- PHP 8.3+
- Laravel 11 or 12

Installation
------------

[](#installation)

```
composer require datascaled/laravel-m365-mailer
```

Quick Start (No DB Logging)
---------------------------

[](#quick-start-no-db-logging)

1. Configure an `m365` mailer in `config/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),
    ],
],
```

2. 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)
----------------------------------

[](#advanced-setup-enable-db-logging)

1. Publish package config and migrations:

```
php artisan vendor:publish --tag="m365-mailer-config"
php artisan vendor:publish --tag="m365-mailer-migrations"
php artisan migrate
```

2. Enable logging in `config/m365-mailer.php` or `.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
-----------------------

[](#configuration-reference)

`config/m365-mailer.php` contains:

- `timeout`
- `save_to_sent_items`
- `cache_store`
- `logging.enabled`
- `logging.retention_days`
- `logging.store_recipients_plaintext`
- `logging.require_database`
- `logging.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-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
-------------------

[](#retention--pruning)

Delete old log data:

```
php artisan m365-mail:prune
```

Override retention window:

```
php artisan m365-mail:prune --days=14
```

Testing
-------

[](#testing)

```
composer test
```

License
-------

[](#license)

MIT

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance82

Actively maintained with recent releases

Popularity12

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

91d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3004ee63747bf06f6d4452342f797534b4a2962e86c1326ac4dc72f3c26940b7?d=identicon)[ramoneg](/maintainers/ramoneg)

---

Top Contributors

[![ramoneg](https://avatars.githubusercontent.com/u/59345351?v=4)](https://github.com/ramoneg "ramoneg (4 commits)")

---

Tags

laravelmailMicrosoft graphm365

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/datascaled-laravel-m365-mailer/health.svg)

```
[![Health](https://phpackages.com/badges/datascaled-laravel-m365-mailer/health.svg)](https://phpackages.com/packages/datascaled-laravel-m365-mailer)
```

###  Alternatives

[spatie/laravel-health

Monitor the health of a Laravel application

87411.3M154](/packages/spatie-laravel-health)[propaganistas/laravel-disposable-email

Disposable email validator

6012.9M7](/packages/propaganistas-laravel-disposable-email)[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[defstudio/telegraph

A laravel facade to interact with Telegram Bots

815320.5k3](/packages/defstudio-telegraph)[illuminate/notifications

The Illuminate Notifications package.

483.0M1.1k](/packages/illuminate-notifications)[harris21/laravel-fuse

Circuit breaker for Laravel queue jobs. Protect your workers from cascading failures.

43140.3k](/packages/harris21-laravel-fuse)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
