Run composer req revision-ten/sendinblue
.
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],
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.
Use the SendinblueService to subscribe users.
Symfony 3.4.* example:
$sendinblueService = $this->container->get(SendinblueService::class);
try {
$subscribed = $sendinblueService->subscribe('dailyNewsletterCampagin', '[email protected]', 'My Website', [
'FNAME' => 'John',
'LNAME' => 'Doe',
]);
} catch (Exception $e) {
// ...
}
Or unsubscribe users:
$sendinblueService = $this->container->get(SendinblueService::class);
$unsubscribed = $sendinblueService->unsubscribe('dailyNewsletterCampagin', '[email protected]');