PHPackages                             sealink/mailchimp-subscribe-craft - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Mail &amp; Notifications](/categories/mail)
4. /
5. sealink/mailchimp-subscribe-craft

ActiveCraft-plugin[Mail &amp; Notifications](/categories/mail)

sealink/mailchimp-subscribe-craft
=================================

Mailchimp Subscribe Plugin for Craft CMS

1.1.3(9y ago)0146PHP

Since Oct 31Pushed 9y ago2 watchersCompare

[ Source](https://github.com/sealink/mailchimp-subscribe-craft)[ Packagist](https://packagist.org/packages/sealink/mailchimp-subscribe-craft)[ RSS](/packages/sealink-mailchimp-subscribe-craft/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (1)Versions (3)Used By (0)

Introduction
------------

[](#introduction)

MailChimp Subscribe for [Craft](http://craftcms.com/) is a plugin for subscribing to a MailChimp newsletter list.

*MailChimp Subscribe requires PHP 5.5 or later.*

Installation
------------

[](#installation)

1. Download and extract the contents of the zip. Put the `mailchimpsubscribe` folder to your Craft plugin folder.
2. Enable the MailChimp Subscribe plugin in Craft (Settings &gt; Plugins).
3. Configure the plugin either in the plugin settings page in the control panel, or configure it via the general config file (see "Configuration" below).
4. Add a form for signing up to your templates (see "Example Usage" below).
5. Eat a banana.

Configuration
-------------

[](#configuration)

To use the plugin you need to create an API key from the MailChimp control panel, and create a list (or use one that you already have).

You can configure MailChimp Subscribe either through the plugins settings in the control panel, or by adding the settings to the general config file (usually found in /craft/config/general.php). Configuring it in the settings file is more flexible, since you can set up the config file to have different settings depending on the environment.

### Example

[](#example)

```
'mcsubApikey' => 'xxxxxxxxxxxxxxxxxxxxx-us2',
'mcsubListId' => '2fd6ec09cf',
'mcsubDoubleOptIn => false

```

If you have multiple lists you want users to subscribe to, each form can have a hidden field with a name of "lid" and the "value" as your list id. The plugin will use this list id on form submit.

### Example

[](#example-1)

```

```

If you want to subscribe to several lists from the same form, you can send in several list id's as a piped list.

### Example

[](#example-2)

```

```

Example Usage
-------------

[](#example-usage)

The following example shows the plugin in use:

```

    {% if mailchimpSubscribe is defined %}
      {% if (not mailchimpSubscribe.success) and (mailchimpSubscribe.errorCode!='1000') %}
        An error occured. Please try again.
      {% endif %}
    {% endif %}

      First name:

      Last name:

      Email:

```

This code assumes that you have a template path newsletter/receipt which the user is redirected to upon successfully signing up to MailChimp. If you want to display the receipt message inside the same template, you just obmit the redirect parameter:

```

    {% if mailchimpSubscribe is defined %}
      {% if (not mailchimpSubscribe.success) and (mailchimpSubscribe.errorCode!='1000') %}
        An error occured. Please try again.
      {% endif %}

      {% if mailchimpSubscribe.success %}
        Thank you for signing up!
      {% endif %}
    {% endif %}

      First name:

      Last name:

      Email:

```

Any other list variables you have configured in MailChimp can be added with formfields with name values like `mcvars[YOURMCVAR]`.

The mailchimpSubscribe object
-----------------------------

[](#the-mailchimpsubscribe-object)

When the plugin returns to the origin template, either if an error occured or successfully posting without a redirect, it will return a mailchimpSubscribe object to the template. It contains the following variables:

**mailchimpSubscribe.success (Boolean):** True or false, depending on if the Subscribe was completed successfully or not.

**mailchimpSubscribe.errorCode (Number):** If an error occured, an error code will also be supplied. See below for a list.

**mailchimpSubscribe.message (String):** A message describing the error. This probably shouldn't be displayed to end users, you should display your own depending on error code.

**mailchimpSubscribe.values (Object):** A structure containing the values that were submitted. For instance mailchimpSubscribe.values.email and mailchimpSubscribe.values.vars.FNAME.

**If you submit multiple list ids are submitted, the mailchimpSubscribe object will contain a listResults array containing the results for each list. If an error occured for one of the lists, the base object will contain the error.**

Ajax submitting
---------------

[](#ajax-submitting)

If the form is submitted with Ajax, the plugin will return a JSON object with the same keys as the template object described above. Big up to [Jake Chapman](https://github.com/imjakechapman) for implementing this. :)

Example:

```
  $('form').on("submit", function(event) {
    event.preventDefault();

    $.post('/', $(this).serialize())
    .done( function(data) {

      if (!data.success)
      {
        // there was an error, do something with data
        alert(data.message);
      }
      else
      {
        // Success
        alert("WEEEEEEEEEE");
      }

    });
  });

```

Groups
------

[](#groups)

Groups can be added by adding a `interests` key to `mcvars`, as an array of interest ids that the user wants to add. You can get the interests connected to a list with the template variable `getListInterestGroups`. MailChimp lets you create different types of groups, checkboxes, radio buttons, dropdown, etc, but doesn't actually limit the add functionality to the groups depending on the type. You have to do this based on the group type. Example:

```

	{% if mailchimpSubscribe is defined %}
		{% if (not mailchimpSubscribe.success) and (mailchimpSubscribe.errorCode!='1000') %}
			An error occured. Please try again.
		{% endif %}

		{% if mailchimpSubscribe.success %}
			Thank you for signing up!
		{% endif %}
	{% endif %}

		First name:

		Last name:

		Email:

	{% set interestGroups = craft.mailchimpSubscribe.getListInterestGroups(craft.config.mcsubListId) %}

	{% if not interestGroups.success %}
		{{ interestGroups.message }}
	{% endif %}

	{% if interestGroups.success and (interestGroups.groups | length > 0) %}
		{% for group in interestGroups.groups %}
			{{ group.title }}

			{% if group.type=='checkboxes' %}
				{% for interest in group.interests %}
					{{ interest.name }}
				{% endfor %}
			{% endif %}

			{% if group.type=='radio' %}
				{% for interest in group.interests %}
					{{ interest.name }}
				{% endfor %}
			{% endif %}

			{% if group.type=='dropdown' %}

					{% for interest in group.interests %}
						{{ interest.name }}
					{% endfor %}

			{% endif %}
		{% endfor %}
	{% endif %}

```

Checking if an email is already on a list
-----------------------------------------

[](#checking-if-an-email-is-already-on-a-list)

Sometimes you might want to know if a user is already on an email list - for example during a cart checkout. It's nice not to bother your existing customers with repeated requests to subscribe to your mailing list, so if this check shows they're already subscribed, you can hide your subscribe form.

Here's an example that should get you started implementing such behaviour:

```
  Check if a user is on our mailing list

      {{ getCsrfInput() }}

      Enter email to check:

   Results:

```

And some jquery to do the actual check:

```
$('#testMCOnList').on('submit', function(e) {

    e.preventDefault();

    $.ajax({
          type: 'POST',
          url: '',
          data: $(this).serialize(),
          success: function( response ) {
            if(response.success){
                $('#results').html("On List");
                 //hide your form here
                 //Also, response.vars.subscriberInfo will contain a bunch of info about the user should you want it
            }
            else{
                $('#results').html("Not On List");
                //display your subscribe form here
            }
          },
    });

});

```

Error codes
-----------

[](#error-codes)

**1000:** Missing or invalid email.
**2000:** Missing API key or List ID.

Any other codes are API errors, and the same code that the MailChimp API returned. [Refer to MailChimp's documentation](http://developer.mailchimp.com/documentation/mailchimp/guides/error-glossary/).

Changelog
---------

[](#changelog)

### Version 1.1.1

[](#version-111)

- Added (non-existing) schema version

### Version 1.1.0

[](#version-110)

- Support for groups was fixed to work with the new API (Thanks, [pabloroman](https://github.com/pabloroman)).
- New `getListInterestGroups` template variable that can be used to get available groups and interests from list.
- Removed old API library.
- Fixed documentation.

### Version 1.0.4

[](#version-104)

- Fixed a small but critical bug that would happen when trying to subscribe and redirect.

### Version 1.0.3

[](#version-103)

- Updated vendor libraries.

### Version 1.0.2

[](#version-102)

- Added option to set interest groups (by [Sam Hibberd](https://github.com/samhibberd)).
- Fixed bug where not supplying any merge vars to checkIsSubscribed would result in an error (by [Sam Hibberd](https://github.com/samhibberd)).

### Version 1.0.1

[](#version-101)

- Fixed missing vendor library.
- Fixed bug where not supplying any merge vars would result in an error.
- Fixed error message.

### Version 1.0.0

[](#version-100)

- Refactored alot of code!
- The plugin is now using the MailChimp API 3.0.
- The plugin now has a service layer that other plugins can tap into.
- Subscribe results from multiple lists are now returned in a separate listResults array in the mailchimpSubscribe variable.
- Added Craft 2.5 plugin stuff.

### Version 0.6

[](#version-06)

- Added new action CheckIsSubscribed to check if an email is already on list [Jeremy Daalder](https://github.com/bossanova808)

### Version 0.5

[](#version-05)

- Added support for disabling double opt-in (particularly useful with Ajax submission).

### Version 0.4

[](#version-04)

- Added support for multiple list id's.

### Version 0.3

[](#version-03)

- Mailchimp Subscribe now returns JSON if form was submitted with Ajax (pull request from [Jake Chapman](https://github.com/imjakechapman)).

### Version 0.2

[](#version-02)

- Fixed noob error, forgot to allow anonymous access to controller.

### Version 0.1

[](#version-01)

- Initial Public Release

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 70.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

2

Last Release

3527d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/45946c89a5950cef3fb99a0d8444653cc013c4f8c862f521086070e9fced092e?d=identicon)[sealink-developers](/maintainers/sealink-developers)

---

Top Contributors

[![aelvan](https://avatars.githubusercontent.com/u/2675644?v=4)](https://github.com/aelvan "aelvan (36 commits)")[![samhibberd](https://avatars.githubusercontent.com/u/1846063?v=4)](https://github.com/samhibberd "samhibberd (5 commits)")[![MartinBlackburn](https://avatars.githubusercontent.com/u/962808?v=4)](https://github.com/MartinBlackburn "MartinBlackburn (2 commits)")[![npedrini](https://avatars.githubusercontent.com/u/1434577?v=4)](https://github.com/npedrini "npedrini (2 commits)")[![a-am](https://avatars.githubusercontent.com/u/976370?v=4)](https://github.com/a-am "a-am (2 commits)")[![scott-davidjones](https://avatars.githubusercontent.com/u/547193?v=4)](https://github.com/scott-davidjones "scott-davidjones (1 commits)")[![alvinypyim](https://avatars.githubusercontent.com/u/10244707?v=4)](https://github.com/alvinypyim "alvinypyim (1 commits)")[![bossanova808](https://avatars.githubusercontent.com/u/731309?v=4)](https://github.com/bossanova808 "bossanova808 (1 commits)")[![imjakechapman](https://avatars.githubusercontent.com/u/1276320?v=4)](https://github.com/imjakechapman "imjakechapman (1 commits)")

### Embed Badge

![Health badge](/badges/sealink-mailchimp-subscribe-craft/health.svg)

```
[![Health](https://phpackages.com/badges/sealink-mailchimp-subscribe-craft/health.svg)](https://phpackages.com/packages/sealink-mailchimp-subscribe-craft)
```

###  Alternatives

[helsingborg-stad/municipio

A bootstrap theme for creating municipality sites.

4028.3k10](/packages/helsingborg-stad-municipio)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

45344.0k1](/packages/pressbooks-pressbooks)[etailors/mautic-amazon-ses

Amazon SES Mailer Plugin for Mautic

573.4k](/packages/etailors-mautic-amazon-ses)[pressbooks/pressbooks-book

This theme is named after Canadian media theorist Marshall McLuhan, who coined the phrase “the medium is the message.” It is designed for academic writing and is also suitable for fiction. Headings are set in Cormorant Garamond, and body type is set in Lora.

206.7k](/packages/pressbooks-pressbooks-book)[dereuromark/cakephp-mailchimp

A CakePHP plugin for MailChimp

2217.9k](/packages/dereuromark-cakephp-mailchimp)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
