adbros/nette-microsoft-mailer
最新稳定版本:v0.2
Composer 安装命令:
composer require adbros/nette-microsoft-mailer
包简介
README 文档
README
This library provides e-mail sending via Microsoft Graph API.
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
- Name:
- 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); } }
统计信息
- 总下载量: 1.44k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-09-23