我就此事联系了 Campaign Monitor 支持人员,并收到了您创建活动所需的信息和发送测试电子邮件的列表。尽管列表可能为空,但我认为您在send_preview
. 在我的例子中,我将 GUID 插入到列表和活动的名称中,以保证名称的唯一性。
发送电子邮件后,您可以立即删除这些临时活动和列表。确保先删除广告系列,因为您无法删除与广告系列相关的列表。
cm_token = {'api_key': settings.CAMPAIGN_MONITOR_ADMIN_API_KEY}
campaign_monitor = CreateSend(cm_token)
cm_list = List(cm_token)
list_id = cm_list.create(email_client_id, "Temporary empty list for preview {}".format(uuid.uuid1()), None, None, None)
# cm_subscribers = []
# for recipient in recipient_list:
# cm_subscriber = Subscriber(cm_token)
# cm_subscriber.add(list_id, recipient[0], "Preview recipient {}".format(uuid.uuid1()), None, None)
# cm_subscribers.append(cm_subscriber)
cm_campaign = Campaign(cm_token)
cm_campaign.create_from_template(
customer_account.email_client_id,
subject,
"Temporary campaign for preview {}".format(template.id), # name
from_email, # from_name
from_email,
from_email, # reply_to
[list_id], # list_ids
None, # segment_ids
template.template_id,
{} # template_content
)
cm_campaign.send_preview(recipient_list[0])
# delete temporary list and campaign
cm_campaign.delete()
cm_list.delete()