39 - Implementing a Mailing List in ExpressionEngine
The last piece of the puzzle on the Train-ee Church Site is implementing an email mailing list for the church to use in communicating with its members.
I know - if you’re reading this you’re probably not a fan of anything email based anymore. RSS feeds, twitter, Facebook - surely there must be a better way for a church to communicate with its members than plain old email?
I agree - but the plain and simple truth of the matter is that for many people email is their internet experience. If your church has a variety of demographic groups you’ll probably need to still use email in order to reach all of them.
Luckily, with EE the implementation is straightforward, the list is double opt-in, and recipients can unsubscribe themselves. Now - creating and sending out regular email missives is still no small task, but at least the list management is handled by ExpressionEngine.
Caveats
The EE Mailing List Module is overall a pretty simplistic tool - I’d say it’s a good one to use if your list is in the 100’s rather than the 1000’s and you’re sending out a few emails a month. You don’t get to track metrics like open rates, etc - and while you can send HTML email there’s no direct way to use an existing EE template as the basis (although there is a 3rd Party Extension that adds that functionality).
If your mailing list needs are more advanced then I’d recommend checking out Campaign Monitor and the CM Extension for EE. As a sidenote, the Campaign Monitor site is itself an ExpressionEngine site, built by Newism - who is writing a series of blog posts about how the job was done.
OK- back to the Church site. Here are the steps required for the task at hand:
- Make Sure the List is Enabled
- Create the mailing list
- Create a new template
- Add the necessary tags to the new template
- Test
Make Sure the List is Enabled
In the Control Panel under Admin › System Preferences › Mailing List Preferences - make sure the “Mailing List is Enabled” option is set to Yes. This is also where you can set notification preferences such that an admin will be notified of new sign-ups to the mailing list. This is nice if you want to send a more personal welcome message or just track the popularity of the list in general.
Create the Mailing List
The mailing list functionality of ExpressionEngine is a module, so to interact with it go to the EE Control Panel and select the Modules tab, then the Mailing List name. From there:
- Click Create New Mailing List
- Fill in the Short Name - I specified “church_newsletter” - this value will be necessary later so make a note of it
- Fill in the Full Name - I specified “Church Newsletter”
- Click “Create”
Note that you can tweak some aspects of the emails that will get sent out - if you want a standard greeting, or each email to always have the church address, service times, and phone/fax number. You can also change the language of the unsubscribe links etc. To do this just find your mailing list in the list and click “Edit Template”.
Create a New Template
OK - back in the Templates area of EE let’s move forward with getting the subscription form on the site.
While on some sites you may implement this subscription form as a sidebar or footer element, for this site it will just live on a dedicated template. I created a “subscribe” template in the default “site” template group, choosing to copy page-comps/one-column-content as it include a newsletter subscription form.
Add EE Tags to site/subscribe
The new template will need the basics configured - page name, body id (which sets the picture that shows), etc - but I trust you’ll figure that out. I want to focus on the core content of the page - the subscription form.
The sample code in the EE docs is a good starting point - so copy that and paste it into your template to work with. Essentially you need to meld together the styling from the template subscribe form with the code from the EE docs - and the result is this:
{exp:mailinglist:form list="church_newsletter"}
<p><strong>Newsletter Sign Up</strong></p>
<p><input type="text" class="form" name="email" value="{email}" /></p>
<p><input type="image" value="submit" src="{site_url}images/interface/send-button.gif" /></p>
{/exp:mailinglist:form}
Note that the short name of the mailing list that I created earlier is specified as a parameter in the opening tag. EE lets you have multiple mailing lists, so this is how you tell EE which list to assign this email address to.
Also note the variable being used in the email text field:
value="{email}"
The email value is a Global Variable and used as is it will default the contents of the email box to the email address of the currently logged-in member. If your site doesn’t use the EE Membership module for more than a content administrator or three, then this is probably unnecessary—but also harmless if left in.
Test Subscribing
With that code in place you should be able to load the rendered page and test the form. Enter in an email address that you can check and submit - you should get a notification message, and then an email with a confirmation link in it. Clicking that link should add your address to the list (note that you can manually remove it again back in the Mailing List Module Interface).
Test Sending
With an address on the list you should now be able to send a message out. Do this by navigating to the Communicate tab in the EE Control Panel. Enter the basics of a message, select the proper Mailing List in the right column, and click Send It. You should get an email a few minutes later and be able to unsubscribe yourself from it.
If you have any issues with the list not working I’d suggest reviewing the Email-related configurations in the EE CP: Admin › System Preferences › Email Configuration, and checking with your webhost to see if what you’ve specified should work. Here on Train-ee I have it set to use Sendmail and it works well.
Is It Over?
Unbelieveably almost a year after beginning this series I believe I have found the end of it! This proved to be a much broader and deeper site than the Small Business Series - and it’s been quite a ride.
What’s Next?
As I promised at the beginning of this series, the next step will be auctioning the completed site off on eBay, and donating the proceeds to a charity. Schedule-wise this will be in a few weeks after the SXSW buzz is over. Then I’ll follow the same model as with the Small Business series in that I’ll use these blog posts as the basis for another book that will be sold here on Train-ee.com. I’m not quite sure how to handle EE 2.0 in regards to this content - so will need to decide that yet.
But for now - chalk up another project as being complete!
Category Navigation







by Mark Dowsett
Date: Thursday, March 12th, 2009
Comment: #1
This was great! Well timed too as I see you just posted this last week. I use other CMSs but was helping a client with his EE site. I’ve never looked at the back-end of EE before but your instructions helped me get thru it VERY quickly….and it all worked!
Now I just want to accomplish sending out the newsletter as an HTML with some nice images and links and I’m all set!