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

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

maize-tech/laravel-msgraph-mailer
=================================

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

1.0.0(5mo ago)91.1k↓32.4%2[5 PRs](https://github.com/maize-tech/laravel-msgraph-mailer/pulls)MITPHPPHP ^8.3CI passing

Since Jan 16Pushed 1mo agoCompare

[ Source](https://github.com/maize-tech/laravel-msgraph-mailer)[ Packagist](https://packagist.org/packages/maize-tech/laravel-msgraph-mailer)[ Docs](https://github.com/maize-tech/laravel-msgraph-mailer)[ GitHub Sponsors](https://github.com/Maize)[ RSS](/packages/maize-tech-laravel-msgraph-mailer/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (1)Dependencies (18)Versions (8)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

47

—

FairBetter than 93% of packages

Maintenance82

Actively maintained with recent releases

Popularity27

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

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

169d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/848d3feb1799fbdb3ff475a4398017f9bc2b94c5cba4dd69d414af62a856fcc4?d=identicon)[maize-tech](/maintainers/maize-tech)

---

Top Contributors

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

---

Tags

azureemaillaravelmailmailermicrosoft-graphoauth2office-365transportlaravelmailemailoauth2azuretransportMicrosoft graphoffice-365

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

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

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

###  Alternatives

[drupal/core

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

21866.0M1.7k](/packages/drupal-core)[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.8M47](/packages/spatie-laravel-pdf)[drupal/core-recommended

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

6942.5M421](/packages/drupal-core-recommended)[propaganistas/laravel-disposable-email

Disposable email validator

6023.0M7](/packages/propaganistas-laravel-disposable-email)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.6M574](/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.

24857.5k](/packages/vormkracht10-laravel-mails)

PHPackages © 2026

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