Skip to content

Latest commit

 

History

History
55 lines (39 loc) · 1.2 KB

README.md

File metadata and controls

55 lines (39 loc) · 1.2 KB

revision-ten/mailchimp

Installation

Install via composer

Run composer req revision-ten/mailchimp.

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\Mailchimp\MailchimpBundle(),

Symfony 4.* /config/bundles.php:

RevisionTen\Mailchimp\MailchimpBundle::class => ['all' => true],

Configuration

Configure the bundle:

# Mailchimp example config.
mailchimp:
    api_key: 'XXXXXXXXXXXXXXXXXXXXXXX-us5' # Your mailchimp api key.
    campaigns:
        dailyNewsletterCampagin:
            list_id: '123456' # Id of your newsletter list.

Usage

Use the MailchimpService to subscribe users.

Symfony 3.4.* example:

$mailchimpService = $this->container->get(MailchimpService::class);

$subscribed = $mailchimpService->subscribe('dailyNewsletterCampagin', '[email protected]', 'My Website', [
    'FNAME' => 'John',
    'LNAME' => 'Doe',
]);

Or unsubscribe users:

$mailchimpService = $this->container->get(MailchimpService::class);

$unsubscribed = $mailchimpService->unsubscribe('dailyNewsletterCampagin', '[email protected]');