PHPackages                             momenoor/laravel-msgraph-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. momenoor/laravel-msgraph-mailer

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

momenoor/laravel-msgraph-mailer
===============================

Laravel mail transport driver for sending emails via Microsoft Graph API with OAuth2 authentication

v1.0.1(4mo ago)05MITPHPPHP ^8.3

Since Apr 8Pushed 4mo agoCompare

[ Source](https://github.com/Momenoor/laravel-msgraph-mailer)[ Packagist](https://packagist.org/packages/momenoor/laravel-msgraph-mailer)[ Docs](https://github.com/momenoor/laravel-msgraph-mailer)[ GitHub Sponsors](https://github.com/Maize)[ RSS](/packages/momenoor-laravel-msgraph-mailer/feed)WikiDiscussions main Synced yesterday

READMEChangelog (1)Dependencies (18)Versions (2)Used By (0)

Laravel Microsoft Graph Mailer
==============================

[](#laravel-microsoft-graph-mailer)

[![Latest Version on Packagist](https://camo.githubusercontent.com/bcaa0ac4504e9c81a1e634fbf9474c31ac9e4b720c2290b1fb70d14d4890e6aa/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d61697a652d746563682f6c61726176656c2d6d7367726170682d6d61696c65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/maize-tech/laravel-msgraph-mailer)[![GitHub Tests Action Status](https://camo.githubusercontent.com/214c143fb156f479b33a75fd7c0e95e635e835764296066bffeff258e88feaa7/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d61697a652d746563682f6c61726176656c2d6d7367726170682d6d61696c65722f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/maize-tech/laravel-msgraph-mailer/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/a28ac876847aeb2443eee69f006ccb0144b86671cd6976a77c93a109adb9da12/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d61697a652d746563682f6c61726176656c2d6d7367726170682d6d61696c65722f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/maize-tech/laravel-msgraph-mailer/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/e586fdc73fd96216c83f212d2092fcb13e4bf29da6790a8bbc9e004957e0d420/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d61697a652d746563682f6c61726176656c2d6d7367726170682d6d61696c65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/maize-tech/laravel-msgraph-mailer)

A Laravel mail transport driver for sending emails via Microsoft Graph API using OAuth2 authentication.

This package provides a custom Symfony Mailer transport that integrates seamlessly with Laravel's mail system, allowing you to send emails through Microsoft 365 (formerly Office 365) using the Microsoft Graph API with application permissions (client credentials flow).

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

[](#installation)

You can install the package via composer:

```
composer require maize-tech/laravel-msgraph-mailer
```

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

[](#configuration)

Add the Microsoft Graph mailer configuration to your `config/mail.php` file:

```
'mailers' => [
    // ... other mailers

    'microsoft-graph' => [
        'transport' => 'microsoft-graph',
        'tenant_id' => env('MICROSOFT_GRAPH_TENANT_ID'),
        'client_id' => env('MICROSOFT_GRAPH_CLIENT_ID'),
        'client_secret' => env('MICROSOFT_GRAPH_CLIENT_SECRET'),
    ],
],
```

Add the required environment variables to your `.env` file:

```
MAIL_MAILER=microsoft-graph

MICROSOFT_GRAPH_TENANT_ID=your-tenant-id
MICROSOFT_GRAPH_CLIENT_ID=your-client-id
MICROSOFT_GRAPH_CLIENT_SECRET=your-client-secret
```

Usage
-----

[](#usage)

Once configured, you can use Laravel's Mail facade as usual. The package will automatically handle OAuth2 authentication and send emails via Microsoft Graph API.

### Basic Email

[](#basic-email)

```
use Illuminate\Support\Facades\Mail;

Mail::raw('Hello from Microsoft Graph!', function ($message) {
    $message->to('recipient@example.com')
            ->subject('Test Email');
});
```

### Using Mailables

[](#using-mailables)

```
use Illuminate\Support\Facades\Mail;
use App\Mail\WelcomeEmail;

Mail::to('user@example.com')->send(new WelcomeEmail($user));
```

### HTML Emails with Attachments

[](#html-emails-with-attachments)

```
use Illuminate\Support\Facades\Mail;

Mail::send('emails.welcome', ['user' => $user], function ($message) use ($user) {
    $message->to($user->email)
            ->subject('Welcome!')
            ->attach('/path/to/file.pdf');
});
```

Token Caching Issues
--------------------

[](#token-caching-issues)

Access tokens are cached for 55 minutes by default. If you need to clear the cache:

```
app('mail.microsoft-graph.token-provider')->clearToken();
```

Features
--------

[](#features)

- **OAuth2 Authentication**: Uses client credentials flow for secure authentication
- **Automatic Token Caching**: Access tokens are cached for 55 minutes
- **Retry Logic**: Automatic retry on transient failures with attempts and delays
- **Full Email Support**:
    - HTML and plain text emails
    - File attachments (including inline images)
    - Multiple recipients (To, CC, BCC)
    - Reply-To headers
- **Laravel Integration**: Works seamlessly with Laravel's Mail facade, Mailables, and Notifications

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)

- [Enrico De Lazzari](https://github.com/enricodelazzari)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance78

Regular maintenance activity

Popularity4

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 83.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

122d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5836882?v=4)[Momen Noor](/maintainers/momenoor)[@Momenoor](https://github.com/Momenoor)

---

Top Contributors

[![enricodelazzari](https://avatars.githubusercontent.com/u/10452445?v=4)](https://github.com/enricodelazzari "enricodelazzari (15 commits)")[![Momenoor](https://avatars.githubusercontent.com/u/5836882?v=4)](https://github.com/Momenoor "Momenoor (2 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")

---

Tags

laravelmailemailoauth2azuretransportMicrosoft graphoffice-365

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/momenoor-laravel-msgraph-mailer/health.svg)

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

###  Alternatives

[maize-tech/laravel-msgraph-mailer

Laravel mail transport driver for sending emails via Microsoft Graph API with OAuth2 authentication

101.3k](/packages/maize-tech-laravel-msgraph-mailer)[drupal/core

Drupal is an open source content management platform powering millions of websites and applications.

19467.3M1.9k](/packages/drupal-core)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6943.5M444](/packages/drupal-core-recommended)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.8M651](/packages/shopware-core)[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)[codebar-ag/laravel-docuware

DocuWare integration with Laravel

1125.1k](/packages/codebar-ag-laravel-docuware)

PHPackages © 2026

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