Skip to end of metadata
Go to start of metadata

Documentation Search

CiviCRM 4.1 Documentation

Developer Resources

CiviCRM books!

Make sure to check out our Online User/Administrator and Developer Guides! You can also support this project by ordering a hard copy.

Or support us by buying an eBook or hard copy of Using CiviCRM from Packt Publishing.

Mailman synchronization

This page describes how to manage Mailman ( lists with CiviCRM Smart Groups.

Subscribing and unsubscribing functions are done through CiviCRM instead of Mailman. Mail delivery and archiving functions remain with Mailman. You should customize various Mailman pages and messages with instructions on how subscribers can unsubscribe or change their email address, instead of Mailman pages. If possible you should disable certain Mailman email command addresses so that people can't change their Mailman subscription via email commands.

If your subscribers have access to their CiviCRM record they may use that to unsubscribe or change their preferences, or you may write a custom interface using the CiviCRM API. While not covered here, under this scenario people could type in their email address and be sent a unique link to click to change their settings.

Prerequisites: The script below assumes you are running CiviCRM and Mailman on the same server but it could be adapted if they are on different servers. You will need sufficient access to run a PHP script and Mailman's sync_members utility on the server. The script extracts list members using the CiviCRM API then calls sync_members.

The script will populate Mailman's real name field in addition to the email address.  

1. Set up a CiviCRM Smart Group for each Mailman list. You can create a Smart Group by first conducting a Search then selecting New Smart Group in the actions drop-down list. The new group will appear in the Manage Groups page. You will need the ID listed against the group, for use in the script below.

2. Copy the script below and save it under the name sync2mailman.php

3. Customize the script according to your setup, including file paths. You will need to customize script and file paths. Add a SyncList(...) call at the bottom of the file for each list.

4. Test the script to make sure it performs how you expect.

5. Remove the -n from $mmcommand to ensure that the changes are actually made

6. Setup a cron. For example "/usr/sbin/php -f /home/myusername/bin/sync2mailman.php"

7. Enjoy !

  • None