0
$newsletter_subject_line = 'Test Mail';
$reply_to = 'test@test.com';
$from_name = 'test@test.com';


$MailChimp = new MailChimp('1234567890thisismyMailchimpAPI');
// Create new Campaign
$result = $MailChimp->post("campaigns", [
    'type' => 'regular',
    'recipients' => ['list_id' => '1234asdf1234'],
    'settings' => ['subject_line' => $newsletter_subject_line,
           'reply_to' => $reply_to,
           'from_name' => $from_name
          ]
    ]);

This is how I send email campaigns via Mailchimp and PHP to a list of users I have. Is there a way that I can send this email to a specific user of this list ?

For example:

'recipients' => ['list_id' => '1234asdf1234/members/1234user1234']
Alcaeus D
  • 258
  • 3
  • 18

1 Answers1

0

The trick is including an array in segment_opts, where each array item is a list of objects. Each object is a new segmentation piece (say, matches this email address, or interested column equals this, etc.)

The keys to each segmentation object are listed as a subset under each condition which can be selected in the dropdown menu in the API docs. You must also include the condition_type as a key-value pair in this object alongside the keys listed by API. This was confusing and poorly written by Mailchimp IMO. My object then, for filtering to a certain email address, was:

// settings and recipients are empty now but must be filled with values you deem necessary
mailchimpCampaignSkeleton = {
    'type': 'regular',
    'settings': {}, 
    'recipients': {
        'segment_opts': {
            'conditions': [
                 {'condition_type': 'EmailAddress',
                  'value': 'fakeEmail@gmail.com,
                  'op': 'is',
                  'field': 'EMAIL'}
            ]
        }
    }
}

This SO post helped me figure this out.

Create campaign with dynamic segment using MailChimp API V3.0