### Install package via Composer Source: https://github.com/jeffersongoncalves/laravel-brevo/blob/main/README.md Use this command to install the package in your Laravel project. ```bash composer require jeffersongoncalves/laravel-brevo ``` -------------------------------- ### Get account details Source: https://github.com/jeffersongoncalves/laravel-brevo/blob/main/README.md Retrieve the authenticated account's details using the Brevo facade. ```php use JeffersonGoncalves\Brevo\Facades\Brevo; $account = Brevo::account(); ``` -------------------------------- ### Publish configuration file Source: https://github.com/jeffersongoncalves/laravel-brevo/blob/main/README.md Publish the package configuration file to your project. ```bash php artisan vendor:publish --tag=brevo-config ``` -------------------------------- ### Configure brevo.php Source: https://github.com/jeffersongoncalves/laravel-brevo/blob/main/README.md The configuration file located at config/brevo.php. ```php // config/brevo.php return [ 'api_url' => env('BREVO_API_URL', 'https://api.brevo.com/v3'), 'api_key' => env('BREVO_API_KEY', ''), 'default_limit' => env('BREVO_DEFAULT_LIMIT', 50), ]; ``` -------------------------------- ### Set API key in .env Source: https://github.com/jeffersongoncalves/laravel-brevo/blob/main/README.md Add your Brevo API key to your environment file. ```env BREVO_API_KEY=your-api-key ``` -------------------------------- ### Run tests with composer test Source: https://github.com/jeffersongoncalves/laravel-brevo/blob/main/README.md Runs the test suite for this Laravel package. Use this command to execute all tests defined in the project. ```bash composer test ``` -------------------------------- ### Manage email campaigns Source: https://github.com/jeffersongoncalves/laravel-brevo/blob/main/README.md List, create, update, send, and delete email campaigns. ```php $campaigns = Brevo::campaigns()->list(['status' => 'sent']); $campaign = Brevo::campaigns()->create( name: 'Summer Sale', sender: ['name' => 'Acme', 'email' => 'sender@example.com'], subject: 'Big Sale', htmlContent: '
Save 20%
', listIds: [2, 3], ); Brevo::campaigns()->update($campaign['id'], ['subject' => 'Updated subject']); Brevo::campaigns()->sendTest($campaign['id'], ['jane@example.com']); Brevo::campaigns()->sendNow($campaign['id']); Brevo::campaigns()->delete($campaign['id']); ``` -------------------------------- ### Manage lists Source: https://github.com/jeffersongoncalves/laravel-brevo/blob/main/README.md Create, update, delete, and manage contacts within lists. ```php $lists = Brevo::lists()->list(); $list = Brevo::lists()->create('Newsletter', folderId: 1); Brevo::lists()->update($list['id'], 'Renamed Newsletter'); $listContacts = Brevo::lists()->contacts($list['id']); Brevo::lists()->addContacts($list['id'], ['jane@example.com']); Brevo::lists()->removeContacts($list['id'], ['jane@example.com']); Brevo::lists()->delete($list['id']); ``` -------------------------------- ### Manage contacts Source: https://github.com/jeffersongoncalves/laravel-brevo/blob/main/README.md Perform CRUD operations and bulk imports on contacts. ```php // List (supports Brevo's contacts filters plus limit/offset) $contacts = Brevo::contacts()->list(['limit' => 20]); $contact = Brevo::contacts()->get('jane@example.com'); // by id or email $contact = Brevo::contacts()->create([ 'email' => 'jane@example.com', 'attributes' => ['FIRSTNAME' => 'Jane', 'LASTNAME' => 'Doe'], 'listIds' => [2, 3], ]); Brevo::contacts()->update('jane@example.com', [ 'attributes' => ['FIRSTNAME' => 'Janet'], 'listIds' => [4], 'unlinkListIds' => [3], ]); Brevo::contacts()->delete('jane@example.com'); // Bulk import Brevo::contacts()->import([ ['email' => 'jane@example.com'], ['email' => 'john@example.com'], ], listIds: [2]); ``` -------------------------------- ### Send transactional email and SMS Source: https://github.com/jeffersongoncalves/laravel-brevo/blob/main/README.md Send emails and SMS messages directly via the Brevo manager. ```php Brevo::sendEmail( senderEmail: 'sender@example.com', senderName: 'Acme', to: [['email' => 'jane@example.com', 'name' => 'Jane']], subject: 'Welcome!', htmlContent: 'Hi Jane
', tags: ['welcome'], ); Brevo::sendSms( sender: 'Acme', recipient: '+15555550100', content: 'Your code is 123456', ); ``` -------------------------------- ### Manage SMS campaigns and senders Source: https://github.com/jeffersongoncalves/laravel-brevo/blob/main/README.md List SMS campaigns and manage sender identities. ```php Brevo::smsCampaigns()->list(['status' => 'sent']); Brevo::senders()->list(); Brevo::senders()->create('Acme', 'sender@example.com'); ``` -------------------------------- ### Handle API errors Source: https://github.com/jeffersongoncalves/laravel-brevo/blob/main/README.md Catch BrevoException to access the decoded error body from non-2xx responses. ```php use JeffersonGoncalves\Brevo\Exceptions\BrevoException; try { Brevo::contacts()->get('missing@example.com'); } catch (BrevoException $e) { logger()->error($e->getMessage(), $e->errorBody()); } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.