sainisch-sczepanski-streller/laravel-graph-api-mail-driver

Send Emails via Microsoft Graph API from your Laravel 10 Project.

1.0.3 2024-03-07 11:57 UTC

This package is auto-updated.

Last update: 2025-07-07 14:48:37 UTC


README

Send Emails via Microsoft Graph API from your Laravel 10 Project.

Description

Minimal Mail driver to send E-Mails via Microsoft Graph API in Laravel.

Don't forget the app permissions and policies in the Graph API. For further info see: Microsoft Docs

Getting started

install

composer require sainisch-sczepanski-streller/laravel-graph-api-mail-driver

.env

MAIL_FROM_ADDRESS=<your sender address>
MAIL_MAILER=microsoft-graph-api
MAIL_MS_GRAPH_CLIENT_ID=<your client id>
MAIL_MS_GRAPH_CLIENT_SECRET=<your client secret>
MAIL_MS_GRAPH_TENANT_ID=<your tenant id>
MAIL_MS_GRAPH_SAVE_TO_SENT_ITEMS=<bool>

config/mail.php

'mailers' => [

        'microsoft-graph-api' => [
            'transport' => 'microsoft-graph-api',
            'client_id' => env('MAIL_MS_GRAPH_CLIENT_ID'),
            'client_secret' => env('MAIL_MS_GRAPH_CLIENT_SECRET'),
            'tenant_id' => env('MAIL_MS_GRAPH_TENANT_ID'),
            'saveToSentItems' => env('MAIL_MS_GRAPH_SAVE_TO_SENT_ITEMS', true),
        ],
...

Usage

Use it like any other Laravel mail driver

 Mail::to([<recipients>])->send(<your mail class>);

Compatibility

Built and tested in Laravel 10

Contributors

License

The MIT License (MIT). Please see license file for more information.