Sending Welcome Email when using Mailchimp API 3 List/Member Method

别等时光非礼了梦想. 提交于 2019-12-12 10:33:45

问题


Is there a way to send the Mailchimp Welcome Email when using Mailchimp API 3 List/Member method? Older API implementations can do it without the need for Automation (paid feature), but I am not sure if API 3 supports it in List/Member method. I am referring to emails that users usually get when they sign up using a standard Mailchimp form.

For instance, this script will not send a Welcome email or any other post-sign up Mailchimp emails.

$apikey = '<api_key>'; 
$auth = base64_encode( 'user:'.$apikey );

$data = array(
       'apikey'        => $apikey,
        'email_address' => $email,
        'status'        => 'subscribed',
        'merge_fields'  => array(
        'FNAME' => $name
            )
);
$json_data = json_encode($data);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://us2.api.mailchimp.com/3.0/lists/<list_id>/members/');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Authorization: Basic '.$auth));
curl_setopt($ch, CURLOPT_USERAGENT, 'PHP-MCAPI/2.0');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json_data);                                                                                                                  

$result = curl_exec($ch); 
var_dump($result);
die('Mailchimp executed');

回答1:


It is very simple: Make sure to turn on the final welcome email in the list settings.

When executing the request set the status to pending. The user wil receive an welcome email in a few minutes.

$data = array(
    'apikey'        => $apikey,
    'email_address' => $email,
    'status'        => 'pending'
);



回答2:


If you turn on the final welcome email for your list it should send when you subscribe. There's currently no way to override the list setting in API v3.0.



来源:https://stackoverflow.com/questions/32243604/sending-welcome-email-when-using-mailchimp-api-3-list-member-method

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!