yieldstudio/laravel-sendinblue-notifier

此包已被弃用且不再维护。作者建议使用 laravel-brevo-notifier 包。

使用 Laravel 通知器轻松发送 Sendinblue 交易性邮件和短信。

1.0.2 2023-04-11 09:43 UTC

This package is auto-updated.

Last update: 2024-01-24 12:54:18 UTC


README

⚠️ 此包已被弃用,建议使用 laravel-brevo-notifier

使用 Laravel 通知器轻松发送 Sendinblue 交易性邮件和短信。

Latest Version GitHub Workflow Status Total Downloads

主版本零 (0.y.z) 用于初始开发。任何内容都可能随时更改。公共 API 不应被视为稳定。

安装

composer require yieldstudio/laravel-sendinblue-notifier

配置

只需定义这些环境变量

SENDINBLUE_IDENTIFIER=
SENDINBLUE_KEY=
MAIL_FROM_ADDRESS=
MAIL_FROM_NAME=
SENDINBLUE_SMS_SENDER=

确保 MAIL_FROM_ADDRESS 是 Sendinblue 上的认证电子邮件。

SENDINBLUE_SMS_SENDER 对字母数字字符限制为 11,对数字字符限制为 15。

您可以使用以下命令发布配置文件

php artisan vendor:publish --provider="YieldStudio\LaravelSendinblueNotifier\SendinblueNotifierServiceProvider" --tag="config"

用法

发送邮件

<?php

namespace App\Notifications;

use Illuminate\Notifications\Notification;
use YieldStudio\LaravelSendinblueNotifier\SendinblueEmailChannel;
use YieldStudio\LaravelSendinblueNotifier\SendinblueEmailMessage;

class OrderConfirmation extends Notification
{
    public function via(): array
    {
        return [SendinblueEmailChannel::class];
    }

    public function toSendinblueEmail($notifiable): SendinblueEmailMessage
    {
        return (new SendinblueEmailMessage())
            ->templateId(1)
            ->to($notifiable->firstname, $notifiable->email)
            ->params(['order_ref' => 'N°0000001']);
    }
}

发送短信

<?php

namespace App\Notifications;

use Illuminate\Notifications\Notification
use YieldStudio\LaravelSendinblueNotifier\SendinblueSmsChannel;
use YieldStudio\LaravelSendinblueNotifier\SendinblueSmsMessage;

class OrderConfirmation extends Notification
{
    public function via()
    {
        return [SendinblueSmsChannel::class];
    }

    public function toSendinblueSms($notifiable): SendinblueSmsMessage
    {
        return (new SendinblueSmsMessage())
            ->from('YIELD')
            ->to('+33626631711')
            ->content('Your order is confirmed.');
    }
}

单元测试

要运行测试,只需运行 composer installcomposer test

变更日志

请参阅 CHANGELOG 了解最近更改的更多信息。

贡献

请参阅 CONTRIBUTING 了解详细信息。

安全

如果您发现与安全相关的错误,请通过 contact@yieldstudio.fr 发送邮件,而不是使用问题跟踪器。

鸣谢

许可

MIT 许可证 (MIT)。请参阅 许可文件 了解更多信息。