PHPackages                             jlorente/yii2-brevo - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Mail &amp; Notifications](/categories/mail)
4. /
5. jlorente/yii2-brevo

ActiveYii2-extension[Mail &amp; Notifications](/categories/mail)

jlorente/yii2-brevo
===================

Yii2 integration for Brevo (Sendinblue) mailer over brevo-php SDK

1.0.2(7mo ago)18MITPHPPHP &gt;=5.6

Since Sep 18Pushed 7mo agoCompare

[ Source](https://github.com/jlorente/yii2-brevo)[ Packagist](https://packagist.org/packages/jlorente/yii2-brevo)[ Docs](https://github.com/jlorente/yii2-brevo)[ RSS](/packages/jlorente-yii2-brevo/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (2)Versions (4)Used By (0)

Yii2 Brevo Mailer
=================

[](#yii2-brevo-mailer)

Yii2 mailer connector for [Brevo](https://www.brevo.com) (formerly Sendinblue).
Provides a seamless integration of the **official [brevo-php SDK](https://github.com/getbrevo/brevo-php)** into Yii2.

This component lets you send either **full custom HTML emails** or **Brevo transactional templates**, and you can deliver them through **Brevo’s Transactional REST API** (via the official SDK) **or through Brevo’s SMTP relay**.

Features include dynamic template parameters, custom subjects, attachments, CC/BCC, default sender configuration, and sandbox mode for safe testing.

---

Installation
------------

[](#installation)

### Package installation

[](#package-installation)

To install, either run

```
$ php composer.phar require jlorente/yii2-brevo "*"
```

or

```
$ composer require jlorente/yii2-brevo "*"
```

or add

```
...
    "require": {
        // ... other configurations ...
        "jlorente/yii2-brevo": "*"
    }
```

to the `require` section of your `composer.json` file and run the following command from your project directory.

```
$ composer update
```

### Component configuration

[](#component-configuration)

Then configure the component in your Yii2 application (for example in `config/main.php` or `common/config/main.php`):

```
...
    'components' => [
        // ... other configurations ...
        'mailer' => [
            'class' => \jlorente\brevo\Mailer::class,
            'apiKey' => env('BREVO_API_KEY'),
            'defaultSender' => [
                'email' => 'noreply@your-domain.com',
                'name'  => 'My App',
            ],
            'sandboxEmail' => 'dev@your-domain.com', // or an array of addresses
            'guzzleConfig' => [
                'timeout' => 10.0,
                // add proxy or other Guzzle options if needed
            ],
            'useFileTransport' => false,
            'viewPath' => '@app/mail',
        ],
    ],
...
```

---

Basic Usage
-----------

[](#basic-usage)

```
    Yii::$app->mailer->compose()
        ->setTo('user@example.com')
        ->setSubject('Hello from Brevo')
        ->setHtmlBody('HelloHTML body')
        ->setTextBody('Hello — plain text body')
        ->send();
```

---

Using Brevo Templates
---------------------

[](#using-brevo-templates)

```
    Yii::$app->mailer->compose()
        ->setTo('user@example.com')
        ->setTemplateId(123456)
        ->setParams([
            'firstName' => 'John',
            // other template parameters
        ])
        ->send();
```

---

Attachments
-----------

[](#attachments)

Attach a file from disk:

```
    Yii::$app->mailer->compose()
        ->setTo('user@example.com')
        ->setSubject('Report attached')
        ->setHtmlBody('Please find the report attached')
        ->attach('/path/report.pdf', [
            'fileName' => 'report.pdf',
            'contentType' => 'application/pdf',
        ])
        ->send();
```

Attach content from memory:

```
    $binary = file_get_contents('/path/generated.pdf');
    Yii::$app->mailer->compose()
        ->setTo('user@example.com')
        ->setSubject('In-memory attachment')
        ->setHtmlBody('See attached file')
        ->attachContent($binary, [
            'fileName' => 'generated.pdf',
            'contentType' => 'application/pdf',
        ])
        ->send();
```

---

Inline / Embed Notes
--------------------

[](#inline--embed-notes)

- Methods `embed()` and `embedContent()` exist to satisfy the Yii2 `MessageInterface`.
- **Warning:** the Brevo transactional REST API does **not** support true inline (CID) images.
    Calling these methods will log a warning and the resource will be sent as a regular attachment, **not** as an inline MIME part.

---

Sandbox Mode
------------

[](#sandbox-mode)

If `sandboxEmail` (string or array) is configured, every outgoing email is redirected to that address or list of addresses, ignoring the original recipients.
This is useful for development, staging, or automated tests to prevent accidental delivery.

---

Technical Notes
---------------

[](#technical-notes)

- Uses the official `getbrevo/brevo-php` SDK.
- A default sender (`defaultSender`) is applied if no `From` address is set on the message.
- `guzzleConfig` lets you customize the underlying Guzzle HTTP client (timeouts, proxy, etc.).
- After sending, you can access the Brevo response via `Message::getLastResponse()` or check exceptions with `Message::getLastException()`.
- Calls to `embed()` or `embedContent()` will log a Yii warning.

---

Contributing
------------

[](#contributing)

1. Fork the repository.
2. Create a feature branch: `git checkout -b feature/my-feature`.
3. Add tests if possible.
4. Submit a pull request with a clear description.

---

License
-------

[](#license)

Copyright © 2025 José Lorente Martín .

Licensed under the MIT license. See LICENSE.txt for details.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance62

Regular maintenance activity

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity32

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

3

Last Release

236d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b5b6d568331349beaf1945db65a076cf60e6c124d504fcb43a21937f0c85bde3?d=identicon)[jlorente](/maintainers/jlorente)

---

Top Contributors

[![jlorente](https://avatars.githubusercontent.com/u/301741?v=4)](https://github.com/jlorente "jlorente (6 commits)")

---

Tags

sdkemailmaileryii2transactionalbrevosendinblue

### Embed Badge

![Health badge](/badges/jlorente-yii2-brevo/health.svg)

```
[![Health](https://phpackages.com/badges/jlorente-yii2-brevo/health.svg)](https://phpackages.com/packages/jlorente-yii2-brevo)
```

###  Alternatives

[boundstate/yii2-mailgun

Mailgun integration for the Yii framework

28160.6k](/packages/boundstate-yii2-mailgun)[hafael/azure-mailer-driver

Supercharge your Laravel or Symfony app with Microsoft Azure Communication Services (ACS)! Effortlessly add email, chat, voice, video, and telephony-over-IP for next-level communication. 🚀

14109.2k](/packages/hafael-azure-mailer-driver)[juanparati/brevosuite

Complete Brevo integration with Laravel

1010.8k](/packages/juanparati-brevosuite)[djagya/yii2-sparkpost

A library provides Yii2 integration with SparkPost mail service

1816.3k](/packages/djagya-yii2-sparkpost)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
