adbros/nette-microsoft-mailer

v0.1 2024-09-19 17:46 UTC

This package is auto-updated.

Last update: 2024-09-23 10:48:14 UTC


README

此库通过 Microsoft Graph API 提供电子邮件发送功能。

main workflow Licence Downloads this Month Downloads total Latest stable

如何安装

composer require adbros/nette-microsoft-mailer

注册邮件发送器

只需重写你的 neon 文件中的默认邮件发送服务。

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

用法

作为标准 Nette 邮件发送器使用。

<?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);
    }
    
}