2017 © Pedro Peláez
 

library mailmotor-bundle

This Symfony bundle loads in MailMotor as a service. So you can subscribe/unsubscribe members to any mailinglist managing API. F.e.: MailChimp, CampaignMonitor, ...

image

mailmotor/mailmotor-bundle

This Symfony bundle loads in MailMotor as a service. So you can subscribe/unsubscribe members to any mailinglist managing API. F.e.: MailChimp, CampaignMonitor, ...

  • Monday, June 11, 2018
  • by jeroendesloovere
  • Repository
  • 2 Watchers
  • 2 Stars
  • 22,273 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 3 Forks
  • 1 Open issues
  • 34 Versions
  • 13 % Grown

The README.md

MailMotorBundle

Latest Stable Version License Build Status Scrutinizer Code Quality, (*1)

Subscribing/Unsubscribing to your own mailinglist has never been this easy! Thanks to this Symfony bundle., (*2)

Installation

How to configure MailChimp

composer require mailmotor/mailchimp-bundle
// In `app/AppKernel.php`
public function registerBundles()
{
    $bundles = array(
        // ...
        new MailMotor\Bundle\MailMotorBundle\MailMotorMailMotorBundle(),
        new MailMotor\Bundle\MailChimpBundle\MailMotorMailChimpBundle(),
    );
# In `app/config/parameters.yml`
parameters:
  # ...
  mailmotor.mail_engine:  'mailchimp' # or another mailmotor engine
  mailmotor.api_key:      xxx # enter your mailchimp api_key here
  mailmotor.list_id:      xxx # enter the mailchimp default list_id here

Examples

Subscribing

$this->get('mailmotor.subscriber')->subscribe(
    $email,         // f.e.: 'info@jeroendesloovere.be'
    $language,      // f.e.: 'nl'
    $mergeFields,   // f.e.: ['FNAME' => 'Jeroen', 'LNAME' => 'Desloovere']
    $interests,     // f.e.: ['9A28948d9' => true, '8998ASAA' => false]
    $doubleOptin,   // OPTIONAL, default = true
    $listId         // OPTIONAL, default listId is in your config parameters
);

Unsubscribing

$this->get('mailmotor.subscriber')->unsubscribe(
    $email,
    $listId // OPTIONAL, default listId is in your config parameters
);

Exists

$this->get('mailmotor.subscriber')->exists(
    $email,
    $listId // OPTIONAL, default listId is in your config parameters
);

Is subscribed

$this->get('mailmotor.subscriber')->isSubscribed(
    $email,
    $listId // OPTIONAL, default listId is in your config parameters
);

Full example for subscribing

use MailMotor\Bundle\MailMotorBundle\Exception\NotImplementedException;

// Don't forget to add validation to your $email
$email = 'info@jeroendesloovere.be';

try {
    if ($this->get('mailmotor.subscriber')->isSubscribed($email)) {
        // Add error to your form
    }
// Fallback for when no mailmotor parameters are defined
} catch (NotImplementedException $e) {
    // Do nothing
}

if ($noErrors)
    try {
        // Subscribe the user to our default group
        $this->get('mailmotor.subscriber')->subscribe(
            $email,
            $language,
            $mergeFields
        );
    // Fallback for when no mailmotor parameters are defined
    } catch (NotImplementedException $e) {
        // Add you own code here to f.e.: send a mail to the admin
    }
}

Full example for unsubscribing

use MailMotor\Bundle\MailMotorBundle\Exception\NotImplementedException;

// Don't forget to add validation to your $email
$email = 'info@jeroendesloovere.be';

try {
    // Email exists
    if ($this->get('mailmotor.subscriber')->exists($email)) {
        // User is already unsubscribed
        if ($this->get('mailmotor.subscriber')->isUnsubscribed($email)) {
            // Add error to your form: "User is already unsubscribed"
        }
    // Email not exists
    } else {
        // Add error to your form: "email is not in mailinglist"
    }
// Fallback for when no mailmotor parameters are defined
} catch (NotImplementedException $e) {
    // Do nothing
}

if ($noErrors) {
    try {
        // Unsubscribe the user
        $this->get('mailmotor.subscriber')->unsubscribe($email);
    // Fallback for when no mailmotor parameters are defined
    } catch (NotImplementedException $e) {
        // We can send a mail to the admin instead
    }
}

Extending

Creating a bundle for another mail engine.

F.e.: You want to use a mail engine called "Crazy"., (*3)

public function registerBundles()
{
    $bundles = array(
        // ...
        new Crazy\Bundle\MailMotorBundle\CrazyMailMotorBundle(),
    );

In app/config/parameters.yml, (*4)

mailmotor.mail_engine:  'crazy'
mailmotor.api_key:      xxx # enter your crazy api_key here
mailmotor.list_id:      xxx # enter the crazy default list_id here

Then you just need to duplicate all files from another mail engine, like f.e.: "mailmotor/mailchimp-bundle" and replace all the logic for your own mail engine., (*5)

Credits

The Versions

11/06 2018

dev-master

9999999-dev https://github.com/mailmotor/mailmotor-bundle

This Symfony bundle loads in MailMotor as a service. So you can subscribe/unsubscribe members to any mailinglist managing API. F.e.: MailChimp, CampaignMonitor, ...

  Sources   Download

MIT

The Requires

 

The Development Requires

php bundle symfony

11/06 2018

3.0.5

3.0.5.0 https://github.com/mailmotor/mailmotor-bundle

This Symfony bundle loads in MailMotor as a service. So you can subscribe/unsubscribe members to any mailinglist managing API. F.e.: MailChimp, CampaignMonitor, ...

  Sources   Download

MIT

The Requires

 

The Development Requires

php bundle symfony

17/05 2018

3.0.4

3.0.4.0 https://github.com/mailmotor/mailmotor-bundle

This Symfony bundle loads in MailMotor as a service. So you can subscribe/unsubscribe members to any mailinglist managing API. F.e.: MailChimp, CampaignMonitor, ...

  Sources   Download

MIT

The Requires

 

The Development Requires

php bundle symfony

26/07 2017

3.0.3

3.0.3.0 https://github.com/mailmotor/mailmotor-bundle

This Symfony bundle loads in MailMotor as a service. So you can subscribe/unsubscribe members to any mailinglist managing API. F.e.: MailChimp, CampaignMonitor, ...

  Sources   Download

MIT

The Requires

 

The Development Requires

php bundle symfony

20/07 2017

3.0.2

3.0.2.0 https://github.com/mailmotor/mailmotor-bundle

This Symfony bundle loads in MailMotor as a service. So you can subscribe/unsubscribe members to any mailinglist managing API. F.e.: MailChimp, CampaignMonitor, ...

  Sources   Download

MIT

The Requires

 

The Development Requires

php bundle symfony

29/06 2017

3.0.1

3.0.1.0 https://github.com/mailmotor/mailmotor-bundle

This Symfony bundle loads in MailMotor as a service. So you can subscribe/unsubscribe members to any mailinglist managing API. F.e.: MailChimp, CampaignMonitor, ...

  Sources   Download

MIT

The Requires

 

The Development Requires

php bundle symfony

20/06 2017

3.0.0

3.0.0.0 https://github.com/mailmotor/mailmotor-bundle

This Symfony bundle loads in MailMotor as a service. So you can subscribe/unsubscribe members to any mailinglist managing API. F.e.: MailChimp, CampaignMonitor, ...

  Sources   Download

MIT

The Requires

 

The Development Requires

php bundle symfony

20/06 2017

dev-php-7-1

dev-php-7-1 https://github.com/mailmotor/mailmotor-bundle

This Symfony bundle loads in MailMotor as a service. So you can subscribe/unsubscribe members to any mailinglist managing API. F.e.: MailChimp, CampaignMonitor, ...

  Sources   Download

MIT

The Requires

 

The Development Requires

php bundle symfony

20/06 2017

dev-add-tags-to-services

dev-add-tags-to-services https://github.com/mailmotor/mailmotor-bundle

This Symfony2 bundle loads in MailMotor as a service. So you can subscribe/unsubscribe members to any mailinglist managing API. F.e.: MailChimp, CampaignMonitor, ...

  Sources   Download

MIT

The Requires

 

The Development Requires

php symfony2 bundle

20/03 2017

2.0.2

2.0.2.0 https://github.com/mailmotor/mailmotor-bundle

This Symfony bundle loads in MailMotor as a service. So you can subscribe/unsubscribe members to any mailinglist managing API. F.e.: MailChimp, CampaignMonitor, ...

  Sources   Download

MIT

The Requires

 

The Development Requires

php bundle symfony

01/12 2016

2.0.1

2.0.1.0 https://github.com/mailmotor/mailmotor-bundle

This Symfony2 bundle loads in MailMotor as a service. So you can subscribe/unsubscribe members to any mailinglist managing API. F.e.: MailChimp, CampaignMonitor, ...

  Sources   Download

MIT

The Requires

 

The Development Requires

php symfony2 bundle

01/12 2016

2.0.0

2.0.0.0 https://github.com/mailmotor/mailmotor-bundle

This Symfony2 bundle loads in MailMotor as a service. So you can subscribe/unsubscribe members to any mailinglist managing API. F.e.: MailChimp, CampaignMonitor, ...

  Sources   Download

MIT

The Requires

 

The Development Requires

php symfony2 bundle

22/11 2016

1.7.3

1.7.3.0 https://github.com/mailmotor/mailmotor-bundle

This Symfony2 bundle loads in MailMotor as a service. So you can subscribe/unsubscribe members to any mailinglist managing API. F.e.: MailChimp, CampaignMonitor, ...

  Sources   Download

MIT

The Requires

 

The Development Requires

php symfony2 bundle

22/11 2016

1.8.0

1.8.0.0 https://github.com/mailmotor/mailmotor-bundle

This Symfony2 bundle loads in MailMotor as a service. So you can subscribe/unsubscribe members to any mailinglist managing API. F.e.: MailChimp, CampaignMonitor, ...

  Sources   Download

MIT

The Requires

 

The Development Requires

php symfony2 bundle

22/11 2016

1.7.2

1.7.2.0 https://github.com/mailmotor/mailmotor-bundle

This Symfony2 bundle loads in MailMotor as a service. So you can subscribe/unsubscribe members to any mailinglist managing API. F.e.: MailChimp, CampaignMonitor, ...

  Sources   Download

MIT

The Requires

 

The Development Requires

php symfony2 bundle

26/05 2016

1.7.1

1.7.1.0 https://github.com/mailmotor/mailmotor-bundle

This Symfony2 bundle loads in MailMotor as a service. So you can subscribe/unsubscribe members to any mailinglist managing API. F.e.: MailChimp, CampaignMonitor, ...

  Sources   Download

MIT

The Requires

 

The Development Requires

php symfony2 bundle

28/04 2016

1.6.1

1.6.1.0 https://github.com/mailmotor/mailmotor-bundle

This Symfony2 bundle loads in MailMotor as a service. So you can subscribe/unsubscribe members to any mailinglist managing API. F.e.: MailChimp, CampaignMonitor, ...

  Sources   Download

MIT

The Requires

 

The Development Requires

php symfony2 bundle

28/04 2016

1.7.0

1.7.0.0 https://github.com/mailmotor/mailmotor-bundle

This Symfony2 bundle loads in MailMotor as a service. So you can subscribe/unsubscribe members to any mailinglist managing API. F.e.: MailChimp, CampaignMonitor, ...

  Sources   Download

MIT

The Requires

 

The Development Requires

php symfony2 bundle

28/04 2016

1.6.0

1.6.0.0 https://github.com/mailmotor/mailmotor-bundle

This Symfony2 bundle loads in MailMotor as a service. So you can subscribe/unsubscribe members to any mailinglist managing API. F.e.: MailChimp, CampaignMonitor, ...

  Sources   Download

MIT

The Requires

 

The Development Requires

php symfony2 bundle

28/04 2016

1.5.0

1.5.0.0 https://github.com/mailmotor/mailmotor-bundle

This Symfony2 bundle loads in MailMotor as a service. So you can subscribe/unsubscribe members to any mailinglist managing API. F.e.: MailChimp, CampaignMonitor, ...

  Sources   Download

MIT

The Requires

 

The Development Requires

php symfony2 bundle

28/04 2016

1.4.2

1.4.2.0 https://github.com/mailmotor/mailmotor-bundle

This Symfony2 bundle loads in MailMotor as a service. So you can subscribe/unsubscribe members to any mailinglist managing API. F.e.: MailChimp, CampaignMonitor, ...

  Sources   Download

MIT

The Requires

 

The Development Requires

php symfony2 bundle

22/03 2016

1.4.1

1.4.1.0 https://github.com/mailmotor/mailmotor-bundle

This Symfony2 bundle loads in MailMotor as a service. So you can subscribe/unsubscribe members to any mailinglist managing API. F.e.: MailChimp, CampaignMonitor, ...

  Sources   Download

MIT

The Requires

 

The Development Requires

php symfony2 bundle

22/03 2016

dev-refactoring

dev-refactoring https://github.com/mailmotor/mailmotor-bundle

This Symfony2 bundle loads in MailMotor as a service. So you can subscribe/unsubscribe members to any mailinglist managing API. F.e.: MailChimp, CampaignMonitor, ...

  Sources   Download

MIT

The Requires

 

The Development Requires

php symfony2 bundle

16/03 2016

1.4.0

1.4.0.0 https://github.com/mailmotor/mailmotor-bundle

This Symfony2 bundle loads in MailMotor as a service. So you can subscribe/unsubscribe members to any mailinglist managing API. F.e.: MailChimp, CampaignMonitor, ...

  Sources   Download

MIT

The Requires

 

The Development Requires

php symfony2 bundle

28/02 2016

1.3.0

1.3.0.0 https://github.com/mailmotor/mailmotor-bundle

This Symfony2 bundle loads in MailMotor as a service. So you can subscribe/unsubscribe members to any mailinglist managing API. F.e.: MailChimp, CampaignMonitor, ...

  Sources   Download

MIT

The Requires

 

The Development Requires

php symfony2 bundle

03/02 2016

1.2.0

1.2.0.0 https://github.com/mailmotor/mailmotor-bundle

This Symfony2 bundle loads in MailMotor as a service. So you can subscribe/unsubscribe members to any mailinglist managing API. F.e.: MailChimp, CampaignMonitor, ...

  Sources   Download

MIT

The Requires

 

The Development Requires

php symfony2 bundle

27/01 2016

1.1.3

1.1.3.0 https://github.com/mailmotor/mailmotor-bundle

This Symfony2 bundle loads in MailMotor as a service. So you can subscribe/unsubscribe members to any mailinglist managing API. F.e.: MailChimp, CampaignMonitor, ...

  Sources   Download

MIT

The Requires

 

The Development Requires

php symfony2 bundle

04/01 2016

1.1.1

1.1.1.0 https://github.com/mailmotor/mailmotor-bundle

This Symfony2 bundle loads in MailMotor as a service. So you can subscribe/unsubscribe members to any mailinglist managing API. F.e.: MailChimp, CampaignMonitor, ...

  Sources   Download

MIT

The Requires

 

The Development Requires

php symfony2 bundle

04/01 2016

1.1.2

1.1.2.0 https://github.com/mailmotor/mailmotor-bundle

This Symfony2 bundle loads in MailMotor as a service. So you can subscribe/unsubscribe members to any mailinglist managing API. F.e.: MailChimp, CampaignMonitor, ...

  Sources   Download

MIT

The Requires

 

The Development Requires

php symfony2 bundle

07/12 2015

1.0.2

1.0.2.0 https://github.com/mailmotor/mailmotor-bundle

This Symfony2 bundle loads in MailMotor as a service. So you can subscribe/unsubscribe members to any mailinglist managing API. F.e.: MailChimp, CampaignMonitor, ...

  Sources   Download

MIT

The Requires

 

The Development Requires

php symfony2 bundle

07/12 2015

1.1.0

1.1.0.0 https://github.com/mailmotor/mailmotor-bundle

This Symfony2 bundle loads in MailMotor as a service. So you can subscribe/unsubscribe members to any mailinglist managing API. F.e.: MailChimp, CampaignMonitor, ...

  Sources   Download

MIT

The Requires

 

The Development Requires

php symfony2 bundle

07/12 2015

1.0.1

1.0.1.0 https://github.com/mailmotor/mailmotor-bundle

This Symfony2 bundle loads in MailMotor as a service. So you can subscribe/unsubscribe members to any mailinglist managing API. F.e.: MailChimp, CampaignMonitor, ...

  Sources   Download

MIT

The Requires

 

The Development Requires

php symfony2 bundle

27/11 2015

1.0.0

1.0.0.0 https://github.com/mailmotor/mailmotor-bundle

This Symfony2 bundle loads in MailMotor as a service. So you can subscribe/unsubscribe members to any mailinglist managing API. F.e.: MailChimp, CampaignMonitor, ...

  Sources   Download

MIT

The Requires

 

The Development Requires

php symfony2 bundle

27/11 2015

0.1.0

0.1.0.0 https://github.com/mailmotor/mailmotor-bundle

This Symfony2 bundle loads in MailMotor as a service. So you can subscribe/unsubscribe members to any mailinglist managing API. F.e.: MailChimp, CampaignMonitor, ...

  Sources   Download

MIT

The Requires

 

The Development Requires

php symfony2 bundle