Integrating CCB with Mailchimp and Mandrill

Today’s tutorial will cover how you can integrate your CCB account to use Mailchimp and Mandrill to send automated email messages.

Before we begin, here’s a quick disclaimer to keep in mind… it is against Mailchimp’s terms of service to send transactional personalized emails.  Because of this, Mailchimp allows for transactional personalized emails to be sent via the service Mandrill.

You may be wondering, “What exactly are transactional personalized emails?” Emails like password reminders, order confirmations, receipts, and personalized notifications qualify as transactional emails because they contain personalized information.

Building on the Birthday Emailer Tutorial

Remember the birthday emailer tutorial? Yes, it too qualifies as a transactional email.  Now you may be thinking, “Why would I send the birthday emailer when I have existing sending capability?”  Great question!

In the birthday emailer tutorial, you’re using good ole’ SMTP and the built-in PHP mailer functionality to send email.  The catch to sending email using PHP mailer is that you must have SMTP enabled and properly setup.

Not to mention that your web/email host could block you from sending such messages in bulk.  So knowing this, you now have a second option for sending messages using Mailchimp and Mandrill.

In addition to the birthday emailer tutorial, we’ll also build upon the search for individuals and cron job tutorials. Let’s get started!

Integrating Mailchimp and Mandrill

For starters, you’ll need to make sure you have both Mailchimp and Mandrill accounts setup and properly integrated.  No worries if you don’t have either set up, I’ve created a quick video that will assist you in getting both set up.

Setting Up Mailchimp Template

I’m not going to spend a lot of time or go into great detail about Mailchimp templates.  There are many features one can capitalize on using Mailchimp templates.  For more on features and a general overview of Mailchimp templates, review the Template overview in Mailchimp’s Knowledge Base.

Below I’ve provided a quick template overview with screenshots.  Log into Mailchimp.

Screen Shot 2015-11-07 at 2.00.50 PM

Now click the Templates link, and then click the Create Template button as shown below.

Screen Shot 2015-11-08 at 6.23.07 PM

You’re then taken to the following page (see below) to start your template creation.  Mailchimp provides some very basic templates to choose from.  Ignore those for now and click the Code Your Own link to the right of the Basic link.

Screen Shot 2015-11-08 at 6.23.30 PM

Once you’ve clicked Code Your Own link, the following page displayed.  It gives you the option to do one of the following:

  • Paste in code – simply use an IDE or Text Editor of your choice (check the Toolbox for IDE options) to create your template, and then copy and paste your code into Mailchimp template.
  • Import HTML – import a HTML from your computer that contains your template file
  • Import Zip – import a zip file containing your template code

For this example, we’ll use the Paste In Code option.

Screen Shot 2015-11-08 at 7.49.27 PM

There are two links at the bottom that will allow you to control the content and the look and feel of the template.  You can click the Edit design link at the bottom to control attributes about the design (i.e., backgrounds, colors, borders, etc.), and the Edit code link to control your template content.

I recommend copying the default code provided by Mailchimp and editing it to your liking via your IDE or Text Editor.  Don’t forget you can use Mailchimp Merge Tags in your content.

Screen Shot 2015-11-08 at 6.25.15 PM

Here’s what the Edit design section looks like.  Once you’re template is to your liking, you can review your template using the Preview and Test feature in the right hand corner.  This allows you to see what your template looks like as well as test send your template via email.

Once your template is complete, you’re now ready to save by clicking Save and Exit in the lower right hand corner.  You’ll be asked to provide a template name.  In this example, we used Test Message as the name of the Template.

Screen Shot 2015-11-08 at 6.25.49 PM

Once you’ve saved your template, you should now see it on the Templates page as you see below.  Now you’re ready to import your template to Mandrill.

But before you go to the next step, ensure that you’ve setup and integrated both your Mailchimp and Mandrill accounts.

Now you’re ready to import.  Click the Edit button to the far right of your template, and select Send to Mandrill link.

Screen Shot 2015-11-08 at 6.33.15 PM

Once your template has been successfully imported, you’ll see it under the Templates section in Mandrill as shown below.

Screen Shot 2015-11-08 at 6.33.54 PM

Okay, so now you have one way to setup a template using Mailchimp and then importing to Mandrill.  But you can also setup a template in Mandrill without using Mailchimp.  I’ll show you how to setup a template in Mandrill next.

Setting Up Mandrill Template

Login to Mandrill and click on the Outbound icon link located on the left hand side of browser (see screenshot below).

Screen Shot 2015-11-07 at 2.15.59 PM

Once you reach the Outbound page, click the Templates link and then the Create a Template button.

Screen Shot 2015-11-07 at 2.16.22 PM

Give your template a name and click the Start Coding button.

Screen Shot 2015-11-07 at 2.17.15 PM

Input all the necessary information into the template fields, and copy and paste your template code from your IDE or Text Editor.

In this template example, I created a simple html birthday message.  By the way, just a reminder, you can also use Mailchimp Merge Tags in Mandrill Templates.

Screen Shot 2015-11-07 at 2.24.08 PM

And just like Mailchimp, Mandrill has a Preview and Test button (see previous screenshot for button located in upper right hand corner.  Once you’ve confirmed your html or text message, simply click the Exit Preview button.

Screen Shot 2015-11-07 at 2.24.29 PM

When you’ve completed your template, you are now ready to publish the template clicking the Publish button.

Screen Shot 2015-11-07 at 2.24.52 PM

Once published, you’ll be shown the following message as shown in the screenshot below.

Screen Shot 2015-11-07 at 2.25.16 PM

And now you have your new template under the Templates section in Mandrill.

Screen Shot 2015-11-07 at 2.25.33 PM

Sending Mailchimp and Mandrill Templates to CCB profiles

Okay, I know you’re ready to sink your teeth into some code, so I’m not going to belabor the point of how to retrieve or search for individual profiles using CCB API.

Below, I’ve included a code example of how you can use Mailchimp and Mandrill Templates to send dynamic notification messages, in this case birthday emails, to your CCB profiles.

Here are a few things about the code that you’ll need to know or do to get things up, running, and sending:

  • Start here reading Mandrill API Documentation
  • Read about and download the Mandrill PHP API
  • Obtain your Mandrill API key (see video above)
  • Include the Mandrill API library in the include directory and in the config.php file
  • You’ll have to make changes to the sendBDayEmail function:
    • Set the $template_name variable
    • Set and uncomment the $template_content should you want to change the content or use dynamic content via Merge Tags; or you can simply put your content in the Template itself in Mailchimp or Mandrill (see examples above)

Although I didn’t use Merge Tags in this example, one subject I recommend you take time to learn more about is using Mailchimp merge tags in Mandrill.  Merge tags will allow you not only to personalize your message, but will open the window to creating and using dynamic content messaging.

For example, does your church use Connection Cards or Guest Cards with various ministry checkboxes (i.e., Membership, Serving, Missions, etc.) for individuals to select?  Simply put, you could create a message system using CCB Process and Queues integrated with Mailchimp and Mandrill that sends emails with content associated to ministry checkboxes selected.

Again this code example uses the birthday emailer as a base and combines it with reusable functions and a more streamlined individual profile search.  To streamline this code more, you may want to look into and research how to input your CCB profile data into a database, and instead of calling the API, use database queries.

Well, that’s it for this tutorial! I hope and pray this tutorial opens to door to all of the various automated messaging opportunities to bring value to your ministry and to grow your ministry.  Let me know if you have questions, and feel free to leave a comment.


Please comment if this tutorial has helped you.