PHPackages                             innoge/laravel-msgraph-mail - 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. innoge/laravel-msgraph-mail

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

innoge/laravel-msgraph-mail
===========================

Laravel Mail driver for Microsoft Office 365 using the MSGraph API

1.5.0(5mo ago)81505.5k↓36.9%251MITPHPPHP ^8.1CI passing

Since Feb 13Pushed 2w ago3 watchersCompare

[ Source](https://github.com/InnoGE/laravel-msgraph-mail)[ Packagist](https://packagist.org/packages/innoge/laravel-msgraph-mail)[ Docs](https://github.com/innoge/laravel-msgraph-mail)[ RSS](/packages/innoge-laravel-msgraph-mail/feed)WikiDiscussions main Synced 2w ago

READMEChangelog (10)Dependencies (10)Versions (21)Used By (1)

Laravel Microsoft Graph Mail Driver Package
===========================================

[](#laravel-microsoft-graph-mail-driver-package)

[![Latest Version on Packagist](https://camo.githubusercontent.com/dcad43945943be1c9aa66318d8d15bc227779feecfe7f67d3733f1f7cab2c5fc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f696e6e6f67652f6c61726176656c2d6d7367726170682d6d61696c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/innoge/laravel-msgraph-mail)[![Laravel Version](https://camo.githubusercontent.com/77ebd277c6386c9898dea6e50fe6c78e48f7ad922d825a7cb5377c30f8798b72/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c61726176656c2d31312e7825374331322e7825374331332e782d6f72616e6765)](https://packagist.org/packages/innoge/laravel-msgraph-mail)[![GitHub Tests Action Status](https://camo.githubusercontent.com/4e52ed831e11ab2b5ff5420a1b2473f188de0e8daf4f38952221e1ee6b4fc1f0/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f696e6e6f67652f6c61726176656c2d6d7367726170682d6d61696c2f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/innoge/laravel-msgraph-mail/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/88eba7ea2440e916fcbd9851cec6ee9556d67ccdd9e59fced46a88bc51a869ed/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f696e6e6f67652f6c61726176656c2d6d7367726170682d6d61696c2f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/innoge/laravel-msgraph-mail/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/668346912de6233e2c103d9f6e749d615ea225ee8538140283f49ade8b467fa8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f696e6e6f67652f6c61726176656c2d6d7367726170682d6d61696c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/innoge/laravel-msgraph-mail)

This package provides a Microsoft Graph mail driver for Laravel. It is an alternative when you don't want to use the deprecated and unsecure Basic Auth SMTP driver with Microsoft Office 365.

Version 2.x supports PHP 8.2+ and Laravel 11–13, authenticates with a client secret or a client certificate, and automatically sends large attachments through Microsoft Graph upload sessions. Upgrading from 1.x? See [UPGRADE.md](UPGRADE.md).

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

[](#installation)

You can install the package via composer:

```
composer require innoge/laravel-msgraph-mail
```

Configuration
-------------

[](#configuration)

### Register the Azure App

[](#register-the-azure-app)

### Microsoft Azure AD Configuration

[](#microsoft-azure-ad-configuration)

I have written a detailed Blog Post how you can configure your Microsoft Azure AD Tenant. [Sending Mails with Laravel and Microsoft Office 365 the secure way](https://geisi.dev/blog/getting-rid-of-deprecated-microsoft-office-365-smtp-mail-sending)

### I want to figure it out on my own

[](#i-want-to-figure-it-out-on-my-own)

You need to register an Azure App in your Azure AD tenant. You can do this by following the steps in the [Microsoft Graph documentation](https://docs.microsoft.com/en-us/graph/auth-register-app-v2).

After creating the App you have to add the following permissions to the App: Mail.Send (Application permission) you will find it under the "Microsoft Graph" section.

Now you have to Grant Admin Consent for the App. You can do this by following the steps in the [Microsoft Graph documentation](https://docs.microsoft.com/en-us/graph/auth-v2-service#3-get-administrator-consent).

### Configuring your Laravel app

[](#configuring-your-laravel-app)

First you need to add a new entry to the mail drivers array in your `config/mail.php` configuration file:

```
'microsoft-graph' => [
    'transport' => 'microsoft-graph',
    'client_id' => env('MICROSOFT_GRAPH_CLIENT_ID'),
    'client_secret' => env('MICROSOFT_GRAPH_CLIENT_SECRET'),
    'tenant_id' => env('MICROSOFT_GRAPH_TENANT_ID'),
    'from' => [
        'address' => env('MAIL_FROM_ADDRESS'),
        'name' => env('MAIL_FROM_NAME'),
    ],
    'save_to_sent_items' =>  env('MAIL_SAVE_TO_SENT_ITEMS', false),
],
```

For the `client_id`, `client_secret` and `tenant_id` you need to use the values from the Azure App you created in the previous step.

The `from` block is optional: when it is omitted entirely, the global `mail.from` configuration is used. The from address must be the primary SMTP address of a real mailbox in your tenant.

Now you can switch your default mail driver to the new `microsoft-graph` driver by setting the env variable:

```
MAIL_MAILER=microsoft-graph
```

### Certificate authentication

[](#certificate-authentication)

Instead of a client secret you can authenticate with a client certificate (no more expiring secrets). Upload the certificate to the Azure app registration (Certificates &amp; secrets → Certificates), then configure:

```
'microsoft-graph' => [
    'transport' => 'microsoft-graph',
    'client_id' => env('MICROSOFT_GRAPH_CLIENT_ID'),
    'tenant_id' => env('MICROSOFT_GRAPH_TENANT_ID'),
    'client_certificate' => [
        'certificate' => env('MICROSOFT_GRAPH_CERTIFICATE'),      // PEM content or file path
        'private_key' => env('MICROSOFT_GRAPH_PRIVATE_KEY'),      // PEM content or file path
        'passphrase' => env('MICROSOFT_GRAPH_KEY_PASSPHRASE'),    // optional
    ],
    // ...
],
```

Both values accept either raw PEM content (starting with `-----BEGIN`) or a path to a PEM file. When `client_certificate` is configured it takes precedence over `client_secret`. Certificate authentication requires the `openssl` PHP extension.

### Saving mails to Sent Items

[](#saving-mails-to-sent-items)

The `save_to_sent_items` option controls whether sent mail is stored in the sender mailbox's "Sent Items" folder (default: `false`). Individual mailables can override the configured default through a Symfony metadata header:

```
use Symfony\Component\Mailer\Header\MetadataHeader;
use Symfony\Component\Mime\Email;

$mailable->withSymfonyMessage(function (Email $message) {
    $message->getHeaders()->add(new MetadataHeader('save-to-sent-items', 'true'));
});
```

### Large attachments

[](#large-attachments)

Messages whose total size exceeds Microsoft Graph's ~4 MB `sendMail` request limit are sent automatically through a draft message with chunked [attachment upload sessions](https://learn.microsoft.com/en-us/graph/outlook-large-attachments). This path additionally requires the **`Mail.ReadWrite`** application permission (plus admin consent). Two things to know:

- Without `Mail.ReadWrite`, large sends throw a `MissingMailReadWritePermission` exception explaining the fix.
- Graph stores a sent draft in Sent Items unconditionally; when `save_to_sent_items` is disabled the package deletes the sent message from Sent Items afterwards (best effort). Failed sends clean up their draft.

AI Agent Support
----------------

[](#ai-agent-support)

This package ships with a [Laravel Boost](https://laravel.com/docs/boost) skill (`msgraph-mail`) covering configuration, troubleshooting, and a step-by-step Azure app registration guide. If your project uses Boost, the skill is installed automatically via `php artisan boost:install` or `php artisan boost:update --discover`.

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Tim Geisendoerfer](https://github.com/InnoGE)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

61

—

FairBetter than 99% of packages

Maintenance85

Actively maintained with recent releases

Popularity54

Moderate usage in the ecosystem

Community26

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 66% 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 ~79 days

Recently: every ~93 days

Total

15

Last Release

173d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/01edc74b3b6f2ecfe6106f68787500e5c46c51acc7fbe7aa04bb378c9190c79b?d=identicon)[geisi](/maintainers/geisi)

---

Top Contributors

[![geisi](https://avatars.githubusercontent.com/u/10728579?v=4)](https://github.com/geisi "geisi (68 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (25 commits)")[![spawnia](https://avatars.githubusercontent.com/u/12158000?v=4)](https://github.com/spawnia "spawnia (5 commits)")[![leeroy869](https://avatars.githubusercontent.com/u/12880155?v=4)](https://github.com/leeroy869 "leeroy869 (3 commits)")[![Heyian](https://avatars.githubusercontent.com/u/8480549?v=4)](https://github.com/Heyian "Heyian (1 commits)")[![joskolenberg](https://avatars.githubusercontent.com/u/26161164?v=4)](https://github.com/joskolenberg "joskolenberg (1 commits)")

---

Tags

laravelinnogelaravel-msgraph-mail

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/innoge-laravel-msgraph-mail/health.svg)

```
[![Health](https://phpackages.com/badges/innoge-laravel-msgraph-mail/health.svg)](https://phpackages.com/packages/innoge-laravel-msgraph-mail)
```

###  Alternatives

[spatie/laravel-permission

Permission handling for Laravel 12 and up

13.0k107.5M1.6k](/packages/spatie-laravel-permission)[dedoc/scramble

Automatic generation of API documentation for Laravel applications.

2.2k12.6M140](/packages/dedoc-scramble)[vormkracht10/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

25060.1k](/packages/vormkracht10-laravel-mails)[illuminate/mail

The Illuminate Mail package.

5910.7M572](/packages/illuminate-mail)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3915.5k](/packages/rawilk-profile-filament-plugin)[backstage/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

25094.0k18](/packages/backstage-laravel-mails)

PHPackages © 2026

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