Easily send Brevo transactional email and sms with Laravel.
You can install the package via composer:
composer require yieldstudio/laravel-brevo-notifier
Just define these environment variables:
BREVO_KEY=
MAIL_FROM_ADDRESS=
MAIL_FROM_NAME=
BREVO_SMS_SENDER=
Make sure that MAIL_FROM_ADDRESS
is an authenticated email on Brevo. You can verify by logging in your Brevo account here https://app.brevo.com/senders
BREVO_SMS_SENDER
is limited to 11 for alphanumeric characters and 15 for numeric characters.
You can publish the configuration file with:
php artisan vendor:publish --provider="YieldStudio\LaravelBrevoNotifier\BrevoNotifierServiceProvider" --tag="config"
Now you can use the channel in your via() method inside the notification:
<?php
namespace App\Notifications;
use Illuminate\Notifications\Notification;
use YieldStudio\LaravelBrevoNotifier\BrevoEmailChannel;
use YieldStudio\LaravelBrevoNotifier\BrevoEmailMessage;
class OrderConfirmation extends Notification
{
public function via(): array
{
return [BrevoEmailChannel::class];
}
public function toBrevoEmail($notifiable): BrevoEmailMessage
{
return (new BrevoEmailMessage())
->templateId(1)
->to($notifiable->firstname, $notifiable->email)
->params(['order_ref' => 'N°0000001']);
}
}
<?php
namespace App\Notifications;
use Illuminate\Notifications\Notification;
use YieldStudio\LaravelBrevoNotifier\BrevoSmsChannel;
use YieldStudio\LaravelBrevoNotifier\BrevoSmsMessage;
class OrderConfirmation extends Notification
{
public function via(): array
{
return [BrevoSmsChannel::class];
}
public function toBrevoSms($notifiable): BrevoSmsMessage
{
return (new BrevoSmsMessage())
->from('YIELD')
->to('+33626631711')
->content('Your order is confirmed.');
}
}
To run the tests, just run composer install
and composer test
.
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
If you've found a bug regarding security please mail [email protected] instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.