Drupal coder

E-mail Marketing Framework Module released : a framework for direct marketing services like Campaign Monitor and Mailchimp

Some time ago I released the Campaign Monitor Advanced module. A module that provides advanced integration with the excellent Campaign Monitor mailing list service. Cool stuff was available in it like support for multiple lists, automatic fetching of lists and fields from your Campaign Monitor account, asynchronous pushing of subscription and unsubscription requests and the ability to match Campaign Monitor custom fields to Drupal tokens, profile fields and PHP code. Cool huh?

Well, you'll be happy to know that all this stuff is available for more services then Campaign Monitor only. I have completely rewritten the module as a framework, called E-mail Marketing Framework, to make it work with virtually every mailing list service that provides an API to some of its functionality. Right now, out the box only MailChimp and Campaign Monitor integration is provided.

Do you work with another service and want to integrate it with Drupal? Well, other then starting from scratch have a look at this module. You can get all of its functionality for your own service if you just tell it how to do some simple tasks like (un)subscribing a user, fetch all available lists, fetch a list of custom fields on a list, ...

If you know some cool features that are missing, help them implement or let us know. We only have to implement them once and they'll be available for all all mailing list services that provide a plugin for this framework.

Have fun using this module.

Extra : writing plugins

Writing plugins for the framework to extend it with other services is quite easy. You just have to create a simple module (like you normally do in Drupal), implement hook_emf_info and you're done. Have a look at the MailChimp implementation that's in the tarball. Below is just a skelleton you could use for your own module.

<?php

/**
 * Implementation of hook_emf_info().
 */
function mailchimp_emf_info() {
  return array(
    'name' => 'MailChimp',
    'file' => 'mailchimp.api.inc',
  );
}

/**
 * Subscribe a user to a list.
 *
 * @param $email
 *   String; E-mail address to subscribe
 * @param $fields
 *   Array; Array of custom field values. Key is field. Value is value for the field.
 * @param $lid
 *   String; List ID of the list to subscribe to.
 * @return
 *   Boolean; TRUE if user is subscribed. FALSE if not.
 */
mailchimp_api_subscribe($email, $fields, $lid);

/**
 * Unsubscribe a user from a list.
 *
 * @param $email
 *   String; E-mail address to subscribe
 * @param $lid
 *   String; List ID of the list to subscribe to.
 * @return
 *   Boolean; TRUE if user is subscribed. FALSE if not.
 */
mailchimp_api_unsubscribe($email, $lid);

/**
 * Fetch subscribed subscribers from API.
 *
 * @param $date
 *   Mixed; If a string, should be in the date() format of 'Y-m-d H:i:s', otherwise, a Unix timestamp.
 * @param $lid
 *   String; List ID
 * @return
 *   Array; List of subscriber lists.
 */
mailchimp_api_get_subscribers_subscribed($date = 0, $lid = NULL);

/**
 * Fetch unsubscribed subscribers from API.
 *
 * @param $date
 *   Mixed; If a string, should be in the date() format of 'Y-m-d H:i:s', otherwise, a Unix timestamp.
 * @param $lid
 *   String; List ID
 * @return
 *   Array; List of subscriber lists.
 */
mailchimp_api_get_subscribers_unsubscribed($date = 0, $lid = NULL);

/**
 * Fetch lists from API.
 *
 * @return
 *   Array; List of subscriber lists.
 */
mailchimp_api_get_lists();

/**
 * Fetch custom fields for some list from API.
 *
 * @param $lid
 *   String; List ID of the list.
 * @return
 *   Array; List of custom fields.
 */
mailchimp_api_get_custom_fields($lid);
October 20, 2009Campaign Monitor, Drupal, emf, modules

Comments

Hello, thanks for your work on this. It's also not clear to me how to actually integrate this. Is it (or will it be) possible to integrate it into a webform? Ideally, I'd like to have a checkbox for people to sign up for the client's newsletter when they submit a general contact request. I'd also like to set up a separate webform just for newsletter signups.

Thanks!

How can one customize the output of the HTML without hacking the module and ruining upgrade?

I want javascript on click for default field values.

Thanks for the module - some great functionality.
Any chance the Drupal project issue queue getting maintained?
Thanks heaps

It's worth noting that EMF only supports one plugin at a time.

The first comment on this list saved me hours of searching through the code.

Please, for the love of God, include some sort of start up documentation.

"Working with MailChimp or Campaign Monitor is pretty easy.
1. Just enable the EMF module and the included MailChimp plugin (or Campaign Monitor plugin) module.
2. Then go to the settings for the plugin (admin/settings/mailchimp or admin/settings/campaign_monitor) and fill in your API key.
3. Run cron (cron.php). This will synchronize all your lists and fields from your Campaign Monitor or MailChimp account.
4. Manage your lists (Administer > Site building > EMF).
I'll try to make a video tutorial when I find some time."

Working with MailChimp or Campaign Monitor is pretty easy.

1. Just enable the EMF module and the included MailChimp plugin (or Campaign Monitor plugin) module.

2. Then go to the settings for the plugin (admin/settings/mailchimp or admin/settings/campaign_monitor) and fill in your API key.

3. Run cron (cron.php). This will synchronize all your lists and fields from your Campaign Monitor or MailChimp account.

4. Manage your lists (Administer > Site building > EMF).

I'll try to make a video tutorial when I find some time.

Same here. We're currently working on a website for a magazine, and they want to be able to integrate the subscriptions with the user profile data. They are using www.listrak.com and the API information can be found here: webservices.listrak.com

I have installed the module but I am unclear on how to integrate mailchimp with it, or where to even begin.

Can you walk me through the set-up process? I am sure that other will find this very useful as well.

Thanks,
Aaron

Hi,

I'd like to integrate this into a webform on our site but can't see / workout if this is possible? Any help would be appreciated.

Thanks,
Darren

Hello from Russia!
Can I quote a post in your blog with the link to you?

Awesome. Just what the doctor ordered!

I'm glad to see this module. A generic framework for this crowded market will be a great way to get some good bulk mail modules written quickly.

I'm really looking forward to using this in a new project, thanks a lot! :-)

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options