$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
]
]);
这是我通过Mailchimp和PHP将电子邮件广告系列发送到我拥有的用户列表的方式。有没有办法可以将此电子邮件发送给此列表的特定用户?
例如:
'recipients' => ['list_id' => '1234asdf1234/members/1234user1234']
答案 0 :(得分:0)
技巧是在segment_opts中包含一个数组,其中每个数组项都是对象列表。每个对象都是一个新的细分片段(例如,匹配此电子邮件地址,或者感兴趣的列等于此,等等)
每个细分对象的键在每种情况下均作为子集列出,可以在API文档的下拉菜单中选择。 您还必须在此对象中将condition_type作为键值对包括在API列出的键旁边。 Mailchimp IMO撰写的这本书令人困惑且写得不好。然后,为了过滤到某个电子邮件地址,我的对象是:
// 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'}
]
}
}
}
这篇SO帖子帮助我弄清楚了这一点。
Create campaign with dynamic segment using MailChimp API V3.0