vitrus/symfony-office-graph-mailer

Symfony Mailer Bridge for Microsoft Graph Api Client

Installs: 207

Dependents: 0

Suggesters: 0

Security: 0

Stars: 4

Watchers: 2

Forks: 1

Open Issues: 0

Type:symfony-mailer-bridge

v0.0.1 2024-01-18 08:36 UTC

This package is auto-updated.

Last update: 2024-04-07 12:21:25 UTC


README

Provides integration between the Symfony Mailer and Office365 Graph API.

  • Tested on:
    • Symfony 6.4 on php 8.1
    • Symfony 5.4 on php 7.4
  • Should work on all Symfony 5.x, 6.x, 7.x instances
    • Feel free to report issues on github if you have them
  • Does not require the Microsoft Graph API Client (speaks to Graph API directly)
  • No Guzzle or other external libraries needed, uses only Symfony HTTP Client and Symfony Mailer

Installation steps

1 add via composer

composer require vitrus/symfony-office-graph-mailer

2 Tag the transport factory in your services.yaml

We might change this package to be a bundle so this is no longer needed in the future

 Vitrus\SymfonyOfficeGraphMailer\Transport\GraphApiTransportFactory:
    tags: ['mailer.transport_factory']

3 configure mailer to use the microsoft-graph-api scheme in .env (or .env.local)

MAILER_DSN=microsoft-graph-api://{CLIENT_ID}:{CLIENT_SECRET}@{TENANT}

The tenant you use here should have permissions to send e-mail, and have access to the user you will configure as sender in your e-mails!

Feature: Store in sent items

Messages are automatically stored in Office 365 Sent Items folder, you can disable this with a custom header:

$message = (new Email())->subject($subject);

// add (falsy) text header to your Email
$message->getHeaders()->addTextHeader('X-Save-To-Sent-Items', 'false');