in Uncategorized

Create and send mailchimp campaign with mlpz/mailchimp-bundle

The mlpz/mailchimp-bundle symphony bundle allows us to interact with Mailchimp API.

Start adding this line on composer.json “require” section:

"require": {
    "mlpz/mailchimp-bundle": "1.3"

After launch composer update command.

php composer.phar mlpz/mailchimp-bundle

Register this bundle on your symfony app/AppKernel.php

public function registerBundles()
    $bundles = array(
        new \MZ\MailChimpBundle\MZMailChimpBundle()

Add your mail chimp api key into app/config.yml (How to create an mail chimp api key)

    api_key: this_is_your_key
    default_list: "this is your default list id"

Add this code on your controller

/** @var MailChimp $mailchimp */
 $campaign->setListId("the list id");
 $campaign->setSubject("Email subject");
 $campaign->setFromName("Your Name");
 $id = $campaign->Create();

If you need extra documentation please check mail chimp bundle project or send a comment.

Write a Comment