revision-ten/sendinblue

A very minimal Sendinblue integration for Symfony

1.2.0 2024-11-06 09:12 UTC

This package is auto-updated.

Last update: 2024-12-06 09:25:18 UTC


README

Installation

Install via composer

Run composer req revision-ten/sendinblue.

Add the Bundle

Add the bundle to your AppKernel (Symfony 3.4.*) or your Bundles.php (Symfony 4.*).

Symfony 3.4.* /app/AppKernel.php:

new \RevisionTen\Sendinblue\Sendinblue\Bundle(),

Symfony 4.* /config/bundles.php:

RevisionTen\Sendinblue\SendinblueBundle::class => ['all' => true],

Configuration

Configure the bundle:

# sendinblue example config.
sendinblue:
    api_key: 'XXXXXXXXXXXXXXXXXXXXXXX-us5' # Your sendinblue api key.
    campaigns:
        dailyNewsletterCampagin:
            list_id: 12345 # ID of your newsletter list.
            doi_template_id: 123 # ID of your double opt-in template.

Usage

Use the SendinblueService to subscribe users.

Symfony 3.4.* example:

$sendinblueService = $this->container->get(SendinblueService::class);

try {
    $subscribed = $sendinblueService->subscribe('dailyNewsletterCampagin', 'visitor.email@domain.tld', 'My Website', [
        'FNAME' => 'John',
        'LNAME' => 'Doe',
    ]);
} catch (Exception $e) {
    // ...
}

Or unsubscribe users:

$sendinblueService = $this->container->get(SendinblueService::class);

$unsubscribed = $sendinblueService->unsubscribe('dailyNewsletterCampagin', 'visitor.email@domain.tld');