Run composer req revision-ten/rapidmail
.
Add the bundle to your AppKernel (Symfony 3.4.*) or your Bundles.php (Symfony 4.*).
Symfony 3.4.* /app/AppKernel.php:
new \RevisionTen\Rapidmail\RapidmailBundle(),
Symfony 4.* /config/bundles.php:
RevisionTen\Rapidmail\RapidmailBundle::class => ['all' => true],
Configure the bundle:
rapidmail:
api_username_hash: 'XXXXXXX'
api_password_hash: 'XXXXXXX'
campaigns:
dailyNewsletterCampagin:
list_id: '123456' # Id of your newsletter list.
Use the RapidmailService to subscribe users.
Symfony 3.4.* example:
$rapidmailService = $this->container->get(RapidmailService::class);
$subscribed = $rapidmailService->subscribe('dailyNewsletterCampagin', '[email protected]', 'My Website', [
'FNAME' => 'John',
'LNAME' => 'Doe',
]);
Or unsubscribe users:
$rapidmailService = $this->container->get(RapidmailService::class);
$unsubscribed = $rapidmailService->unsubscribe('dailyNewsletterCampagin', '[email protected]');