10

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');
Community
  • 1
  • 1
Edville
  • 345
  • 1
  • 5
  • 18

2 Answers2

7

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'
);
Robin
  • 71
  • 1
  • 2
  • Do you know if this needs the status as Pending? Can the same be achieve but automatically including the user into the mailing list (ideally adding it to a group)? – mmalmeida Oct 20 '16 at 11:17
  • 1
    This is the trick! Status = "subscribed" doesn't send the welcome mail (but subscribes directly, status = "pending" does send the welcome mail and respects the double opt-in. – Wietse Dec 02 '16 at 14:05
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.

TooMuchPete
  • 4,583
  • 2
  • 17
  • 21
  • I am not trying to override anything. There is nothing in default Mailchimp.com setting I want to override. The setting already allows welcome email to be sent – Edville Aug 28 '15 at 21:28
  • You should get in touch with API support, then -- if you've got the list form set to send a final welcome email, API subscriptions should do it. – TooMuchPete Aug 29 '15 at 04:08