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);
Written on October 20, 2009 at 11:51, tagged as Drupal, emf, modules

Comments

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

About

drupalcoder.com is a blog on all things Drupal in specific and LAMP on OS X in general. It is maintained by Davy Van Den Bremt, a Belgian (Drupal) web developer and designer living in Ghent. The goal of this blog is to log all interesting things that have crossed the writer's path while developing Drupal sites. You can read all about Davy's professional activities on his LinkedIn profile. If you want to get in touch, use the contact form.