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

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

victord11/laravel-msgraph-mail
==============================

Laravel Mail driver for Microsoft Office 365 using the MSGraph API

v1.0.0(10mo ago)017MITPHPPHP ^8.1CI passing

Since Jul 3Pushed 10mo agoCompare

[ Source](https://github.com/VictoRD11/laravel-msgraph-mail)[ Packagist](https://packagist.org/packages/victord11/laravel-msgraph-mail)[ Docs](https://github.com/victord11/laravel-msgraph-mail)[ RSS](/packages/victord11-laravel-msgraph-mail/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (12)Versions (3)Used By (0)

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

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

[![Latest Version on Packagist](https://camo.githubusercontent.com/34dcf6f38088aa50980414eee21cc36f036a73e5c934d85e9d3ef4ec99de9b23/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f766963746f726431312f6c61726176656c2d6d7367726170682d6d61696c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/victord11/laravel-msgraph-mail)[![GitHub Tests Action Status](https://camo.githubusercontent.com/75da42ba13bc76c0138ebfcc31d178e41a96d94487e579f10c75959ba1edf29f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f766963746f726431312f6c61726176656c2d6d7367726170682d6d61696c2f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/victord11/laravel-msgraph-mail/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/2a47e77360a2933596b87271c345e3c9c647572e433b8144dc96fe319245a8b0/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f766963746f726431312f6c61726176656c2d6d7367726170682d6d61696c2f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/victord11/laravel-msgraph-mail/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/a31b7537d46702b69e20732624781440c64fc7df31e40ae44939e7ec07db76bb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f766963746f726431312f6c61726176656c2d6d7367726170682d6d61696c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/victord11/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.

**This package it's a fork of the InnoGE/laravel-msgraph-mail package, which is no implemented password grant authentication. It has been improved to support both Client Credentials and Resource Owner Password Credentials authentication methods.**

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

[](#installation)

You can install the package via composer:

```
composer require victord11/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:

### Client Credentials Authentication (Default)

[](#client-credentials-authentication-default)

```
'microsoft-graph' => [
    'transport' => 'microsoft-graph',
    'auth_method' => 'client_credentials',
    '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),
],
```

### Resource Owner Password Credentials Authentication

[](#resource-owner-password-credentials-authentication)

```
'microsoft-graph' => [
    'transport' => 'microsoft-graph',
    'auth_method' => 'password',
    'client_id' => env('MICROSOFT_GRAPH_CLIENT_ID'),
    'client_secret' => env('MICROSOFT_GRAPH_CLIENT_SECRET'),
    'tenant_id' => env('MICROSOFT_GRAPH_TENANT_ID'),
    'username' => env('MICROSOFT_GRAPH_USERNAME'),
    'password' => env('MICROSOFT_GRAPH_PASSWORD'),
    '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.

**Note**: The `client_credentials` method is recommended for production use as it's more secure. The `password` method should only be used when necessary and in secure environments.

The `save_to_sent_items` option in Microsoft Graph refers to a parameter that determines whether a sent email should be saved to the sender's "Sent Items" folder within their mailbox. When this option is set to true, the email will be automatically saved to the "Sent Items" folder, providing a record of the communication. Conversely, when it's set to false, the email will not be saved to the "Sent Items" folder.

By default, the save\_to\_sent\_items option is set to false, which means that emails sent through Microsoft Graph won't be saved in the sender's "Sent Items" folder unless explicitly specified otherwise. This behavior can be useful in scenarios where you might want more control over which emails are saved as sent items, perhaps to reduce clutter or ensure confidentiality.

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

```
MAIL_MAILER=microsoft-graph
```

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)

- [Mazur Viktor](https://github.com/VictoRD11)
- [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

31

—

LowBetter than 68% of packages

Maintenance54

Moderate activity, may be stable

Popularity7

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 62.3% 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

Unknown

Total

1

Last Release

313d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b2ab046812456439266721ae8bb426e4c0c107be552f30ac022e6927eca4c8c5?d=identicon)[VictoRD11](/maintainers/VictoRD11)

---

Top Contributors

[![geisi](https://avatars.githubusercontent.com/u/10728579?v=4)](https://github.com/geisi "geisi (38 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (15 commits)")[![spawnia](https://avatars.githubusercontent.com/u/12158000?v=4)](https://github.com/spawnia "spawnia (5 commits)")[![VictoRD11](https://avatars.githubusercontent.com/u/311195?v=4)](https://github.com/VictoRD11 "VictoRD11 (2 commits)")[![joskolenberg](https://avatars.githubusercontent.com/u/26161164?v=4)](https://github.com/joskolenberg "joskolenberg (1 commits)")

---

Tags

laravelmicrosoftinnogelaravel-msgraph-mailMicrosoft graphvictord11

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

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

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

###  Alternatives

[innoge/laravel-msgraph-mail

Laravel Mail driver for Microsoft Office 365 using the MSGraph API

73330.8k2](/packages/innoge-laravel-msgraph-mail)[vormkracht10/laravel-mails

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

24149.7k](/packages/vormkracht10-laravel-mails)[xammie/mailbook

Laravel Mail Explorer

482458.3k1](/packages/xammie-mailbook)[spatie/laravel-notification-log

Log notifications sent by your Laravel app

207902.8k](/packages/spatie-laravel-notification-log)[wnx/laravel-sends

Keep track of outgoing emails in your Laravel application.

200427.3k](/packages/wnx-laravel-sends)[spatie/laravel-discord-alerts

Send a message to Discord

151408.0k](/packages/spatie-laravel-discord-alerts)

PHPackages © 2026

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