Adam Rich


Email::ConstantContact - Perl interface to the ConstantContact API


Version 0.05


This module allows you to interact with the ConstantContact mass email marketing service from perl, such as creating and mainting contacts and contact lists.

Before using this module, you must register your application with the ConstantContact company, agree to their terms & conditions, and apply for an API access key. You will use this key, in combination with a ConstantContact username and password to interact with the service.

    use Email::ConstantContact;

    my $apikey = 'ABCDEFG1234567';
    my $username = 'mycompany';
    my $password = 'topsecret';

    my $cc = new Email::ConstantContact($apikey, $username, $password);

    # How to enumerate existing Contact Lists:
    my @all_lists = $cc->lists();
    foreach my $list (@all_lists) {
        print "Found list: ", $list->{Name}, "\n";

    # How to create a new Contact List:
    my $new_list = $cc->newList('JAPH Newsletter', {
        SortOrder               => '70',
        DisplayOnSignup         => 'false',
        OptInDefault            => 'false',

    # How to add a new contact:
    my $new_contact = $cc->newContact('', {
        FirstName       => 'John',
        LastName        => 'Doe',
        CompanyName     => 'JD Industries',
        ContactLists    => [ $new_list ],

    # How to modify existing contact:
    my $old_contact = $cc->getContact('');
    print "Yogi no longer works for ", $old_contact->{CompanyName}, "\n";
    $old_contact->{CompanyName} = 'Acme Corp';

    # Enumerate List Membership
    print "Member of Lists: \n";
    foreach my $listid (@{ $old_contact->{ContactLists} }) {
        my $listobj = $cc->getList($listid);
        print $listobj->{Name}, "\n";

    # Manage List Membership

    # Opt-Out of all future emails

    # Display recent activities
    my @recent_activities = $cc->activities();

    foreach my $activity (@recent_activities) {
        print "Found recent activity, Type= ", $activity->{Type}, 
            "Status= ", $activity->{Status}, "\n";

        # Obtain bounced email addresses.
        foreach my $camp ($cc->campaigns('SENT')) {
                foreach my $event ($camp->events('bounces')) {
                        if ($event->{Code} eq 'B') {
                                print "Bounced: ", $event->{Contact}->{EmailAddress}, "\n";


  • Implement method for enumerating members of a specified list.

  • Implement method for enumerating contacts

  • Implement method for enumerating campaign events per contact

  • Implement method for enumerating campaign contacts per event

  • Implement methods for bulk operations (import/export)


Adam Rich, <arich at>


Please report any bugs or feature requests to bug-email-constantcontact at, or through the web interface at I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.


You can find documentation for this module with the perldoc command.

    perldoc Email::ConstantContact

You can also look for information at:


Copyright 2009-2011 Adam Rich, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.