bhekor/laravel-brevo

Laravel package for Brevo (ex-Sendinblue) API integration

v1.0.0 2025-05-31 11:12 UTC

This package is auto-updated.

Last update: 2025-05-31 11:24:09 UTC


README

Complete Brevo (formerly Sendinblue) integration for Laravel, including email support, webhook handling, and optional Vue components.

Latest Version on Packagist Total Downloads GitHub Tests Action Status PHPStan License PHP Version Support Laravel Version Support

Features

  • Seamless integration with Laravel's Mail facade
  • Full support for Markdown Mailables
  • Multiple usage options (default mailer, explicit mailer, facade)
  • Webhook handling
  • Optional Vue components for analytics
  • Comprehensive error handling
  • Modern PHP & Laravel practices (strict typing, PSR-12, PHPDoc)

Installation

composer require bhekor/laravel-brevo

Configuration

Publish the config file:

php artisan vendor:publish --tag=brevo-config

Set your API key and sender details in your .env:

MAIL_MAILER=brevo
BREVO_API_KEY=your_api_key
BREVO_FROM_EMAIL=noreply@example.com
BREVO_FROM_NAME="Your App"

Frontend Integration (Optional)

Install frontend dependencies:

npm install --save-dev @vueuse/core chart.js
php artisan vendor:publish --tag=brevo-assets

In your resources/js/app.js:

import Brevo from '../../public/vendor/laravel-brevo/brevo';
import { createApp } from 'vue';

const app = createApp({});
app.use(Brevo, {
    apiBaseUrl: '/brevo-api'
});

Use components in your Vue template:

<template>
  <BrevoStats />
  <BrevoWebhookLogs />
</template>

Usage

Regular Mailable

Mail::to('user@example.com')->send(new OrderShipped());

Markdown Mailable

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;

class OrderShipped extends Mailable
{
    use Queueable, SerializesModels;

    public function build()
    {
        return $this->markdown('emails.orders.shipped')
                    ->with([
                        'order' => $this->order,
                    ]);
    }
}

Using the Facade

Brevo::email()->send(new OrderShipped());

Webhooks

  1. Register your webhook endpoint in the Brevo dashboard.
  2. Add the following to your routes/api.php:
Route::brevoWebhooks('/brevo/webhook');

Testing

composer test

Security Vulnerabilities

Please report any security vulnerabilities to security@bhekor.com.

Test Suite

The package includes a robust set of unit and feature tests to ensure reliability.

Directory Structure

tests/
├── Feature/
│   ├── MailTransportTest.php
│   └── WebhookTest.php
└── Unit/
    ├── BrevoClientTest.php
    ├── EventMapperTest.php
    ├── MailTransportTest.php
    ├── TransactionalEmailTest.php
    └── WebhookControllerTest.php

Run all tests with:

composer test

Or use PHPUnit directly:

./vendor/bin/phpunit

Package Structure

bhekor/
└── laravel-brevo/
    ├── config/
    │   └── brevo.php
    ├── resources/
    │   └── js/
    │       ├── components/
    │       │   ├── BrevoStats.vue
    │       │   └── BrevoWebhookLogs.vue
    │       └── brevo.js
    ├── src/
    │   ├── BrevoServiceProvider.php
    │   ├── Contracts/
    │   │   ├── BrevoClientInterface.php
    │   │   └── MailTransportInterface.php
    │   ├── Exceptions/
    │   │   ├── BrevoApiException.php
    │   │   ├── BrevoConfigurationException.php
    │   │   └── BrevoValidationException.php
    │   ├── Facades/
    │   │   └── Brevo.php
    │   ├── Mail/
    │   │   └── BrevoTransport.php
    │   ├── Services/
    │   │   ├── BrevoClient.php
    │   │   └── TransactionalEmail.php
    │   └── Webhooks/
    │       ├── EventMapper.php
    │       ├── WebhookController.php
    │       └── routes.php
    ├── tests/
    │   ├── Feature/
    │   │   ├── MailTransportTest.php
    │   │   └── WebhookTest.php
    │   └── Unit/
    │       ├── BrevoClientTest.php
    │       ├── EventMapperTest.php
    │       ├── MailTransportTest.php
    │       ├── TransactionalEmailTest.php
    │       └── WebhookControllerTest.php
    ├── composer.json
    ├── package.json
    └── README.md