New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

adbros/nette-microsoft-mailer

Package Overview
Dependencies
Maintainers
0
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

adbros/nette-microsoft-mailer

Source
Packagist
Version
v0.2
Version published
Total downloads
2.6K
Maintainers
0
Created
Source

Nette Microsoft Mailer

This library provides e-mail sending via Microsoft Graph API.

main workflow Licence Downloads this Month Downloads total Latest stable

How to install

composer require adbros/nette-microsoft-mailer

Azure setup

Register an application in Azure Portal

  • Go to Azure Portal
  • Go to Microsoft Entra ID -> App registrations
  • Click on "New registration"
  • Fill in the form:
    • Name: Your app name
    • Supported account types: Accounts in this organizational directory only (Single tenant)
    • Redirect URI: http://localhost
  • Save
    • Application (client) ID
    • Directory (tenant) ID
    • Client secret (create a new one in the "Certificates & secrets" tab)

API permissions

  • Go to API permissions
  • Click on "Add a permission"
  • Select "Microsoft Graph" => Application permissions
  • Select Mail.Send
  • Click on "Grant admin consent"

Register mailer

Just rewrite the default mailer service in your neon file.

services:
	mail.mailer: Adbros\MicrosoftMailer\MicrosoftMailer(
		tenantId: 'tenant_id'
		clientId: 'client_id'
		clientSecret: 'client_secret'
		defaultSender: 'default_sender_email'
	)

Usage

Use as standard Nette Mailer.

<?php

use Nette\Mail\Mailer;
use Nette\Mail\Message;

class SomeClass
{

    public function __construct(
        private Mailer $mailer,
    ) 
    {    
    }
    
    public function sendEmail(): void
    {
        $message = new Message();
        $message->setSubject('Hello World!');
        $message->setHtmlBody('<h1>Hello World!</h1>');
        $message->addTo('john.doe@example.org');
        
        $this->mailer->send($message);
    }
    
}

FAQs

Package last updated on 19 Mar 2025

Related posts