moegrain/laravel-sendinblue-template

一个用于 SendinBlue API v3 官方 PHP 库的 Laravel 7/8/9 服务提供者、外观和配置文件。

v1.1.0 2024-06-16 13:57 UTC

This package is auto-updated.

Last update: 2024-09-16 14:42:51 UTC


README

Latest Version on Packagist Total Downloads License

该软件包仅提供了一个 Laravel 服务提供者、外观和配置文件,用于 SendinBlue 的 API v3 官方 PHP 库。 https://github.com/sendinblue/APIv3-php-library

它还允许使用 SendInBlue 交易模板简单发送 Laravel 通知。

安装

您可以通过 Composer 安装此软件包,使用以下命令:

composer require mograine/laravel-sendinblue-template-template

配置

您需要将配置文件发布到 app/config/sendinblue.php。要做到这一点,请运行:

php artisan vendor:publish --tag=sendinblue.config

现在您需要使用 环境变量 来设置配置。前往 Sendinblue API 设置,并将 v3 API 密钥添加到您的 .env 文件中。

SENDINBLUE_API_KEY=xkeysib-XXXXXXXXXXXXXXXXXXX
SENDINBLUE_EMAIL=defaultEmail
SENDINBLUE_NAME=defaultName

使用方法

该软件包提供了一个内置的通知通道,用于发送交易模板电子邮件。

要测试它,请使用 php artisan make:notification 命令创建一个新的通知。

使用示例

<?php

namespace App\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Mograine\Sendinblue\SendinblueMailTemplateChannel;
use Mograine\Sendinblue\TemplateMessage;

class NewOfferNotification extends Notification
{
    use Queueable;

    public function via($notifiable)
    {
        return [ SendinblueMailTemplateChannel::class ];
    }

    public function toMailTemplate($notifiable): TemplateMessage
    {
        $templateId = 1;
        $templateMessage = new TemplateMessage($templateId);
        $templateMessage->attribute('USER_EMAIL', $notifiable->email);
        return $templateMessage;
    }
}

您还可以使用内置的 getAPI 方法获取任何 V3 SendInBlue API。

use Mograine\Sendinblue\SendinblueApiEnum;
use Mograine\Sendinblue\Facades\Sendinblue;

// We first get the API we want
$transactionalApi = Sendinblue::getApi(SendinblueApiEnum::TransactionalEmailsApi);

// We can then easily use it, example :
$transactionalApi->deleteBlockedDomain('exampleSendinblueDomain.com');

请务必访问 SendinBlue 官方 文档网站 获取有关 API 的更多信息。

贡献

有关详细信息以及待办事项列表,请参阅 contributing.md

安全

如果您发现任何与安全相关的问题,请通过电子邮件联系作者,而不是使用问题跟踪器。

许可证

许可证。有关更多信息,请参阅 许可证文件