3

I am executing a curl call via php to Mailchimp API v3.0. When a user sign up to my cms, I sent him a confirmation email and add a member to a specific Mailchimp list, calling this URL:

'https://us11.api.mailchimp.com/3.0/lists/'.$list_id.'/members/';

passing those parameters:

$data = array(
    'apikey'            => $apikey,
    'email_address'     => $mailchimp_user['email'],
    'status'            => 'pending',
    'update_existing'   => true,
    'send_welcome'      => false,
    'double_optin'      => false,
    'merge_fields'      => array(
        'FNAME'             => $mailchimp_user['FNAME'],
        'LNAME'             => $mailchimp_user['LNAME']
    )
);

The Mailchimp pending subscription is successful. When the user click in the confirmation email sent from my cms, with another curl (PATCH method) call, I can easily update the member status to 'subscribed'. So I can manage all the Mailchimp subscription from my cms, without any Mailchimp default behavior and layouts.

But the default Mailchimp Confirmation email is never sent to the user, even if the 'double_optin' param is false.

I noticed that if I set the member status to 'unsubscribed' the user did not receive the confirmation email. But it is logically wrong! I'd like that the two steps for Mailchimp subscription should be
pending -> subscribed
and not
unsubscribed -> subscribed.

Can I do something about it?

ekad
  • 14,436
  • 26
  • 44
  • 46
  • Try this one. It should solve your problem. http://stackoverflow.com/questions/30531798/updating-subscribers-in-a-list-using-curl-and-mailchimp-api-v3/42282976#42282976 – Faisal Feb 16 '17 at 19:35

2 Answers2

11

You seem to be mixing the v2.0 API and the v3.0 API. In v3.0, you shouldn't be passing your API key in the body of your request and there is no double_opt_in flag. Within MailChimp, if you set a user to pending, they will always be sent a confirmation email. v2.0 and v3.0 handle that different. In v2.0, passing double_opt_in as true results in a pending member who gets a confirmation email. Passing it as false results in a subscribed member.

In v3.0, setting status to pending sends a confirmation email.

TooMuchPete
  • 4,583
  • 2
  • 17
  • 21
  • Thanks, now it is all clear! I will register an unsubscribed user for the pending status. And then upgrade that user to subscribed when he will click on the confirmation email sended from my cms. – Lorenzo Gasperoni Sep 19 '15 at 07:46
  • 1
    @LorenzoGasperoni did you ever find a way to do what you are describing? If your CMS sends its own confirmation email, then they would get two: one from you and one from MailChimp. – Yaron Feb 17 '17 at 00:50
  • @Yaron yes, if you want to manage the subscription using your site and not the Mailchimpt Double Opt in, the solutions can be: - to send a custom confirmation email and send him as subscribed only if he click on the link in the confirmation email; - to send the user as 'unsubscribed' and update the status to 'subscribed' if he click on the link in the confirmation email; If you send the user to mailchimp with the status 'pending', he will receive the automated email from Mailchimp, risking double confirmation emails. – Lorenzo Gasperoni Mar 06 '17 at 11:26
1

The internal pending status of mailchimp API v3 is not there so you manage manual double opt-in for your users. It is there so that mailchimp can sent their own automated double opt-in emails to the users.

To achieve a manual double opt-in you should do the following:

  1. when user submits your form on your client-side, make a POST request to mailchimp api v3 and add a new user to your list as unsubscribed

  2. send the user an email using mandrill or some other service. The purpose of this mail would be that he accepts to be subscribed into your list.

  3. when user clicks on the mail make a PATCH request to mailchimp api v3 and update user to subscribed.

You can find more details here, and here.