1-866-284-2541  |  Registered Users LOGIN 

MailChimp Home Learn More Pricing Resource Center Blog Free Trial

MailChimp API
Back to Documentation Overview

listBatchUnsubscribe

public static listBatchUnsubscribe(string uid, string id, array emails, boolean delete_member, boolean send_goodbye, boolean send_notify)

Unsubscribe a batch of email addresses to a list


Section:
List Related

Parameters:
uid the id for your user account. Get by calling login($user, $pass)
id the list id to connect to
emails array of email addresses to unsubscribe
delete_member flag to completely delete the member from your list instead of just unsubscribing, default to false
send_goodbye flag to send the goodbye email to the email addresses, defaults to true
send_notify flag to send the unsubscribe notification email to the address defined in the list email notification settings, defaults to false

Returns:
struct   -  Array of result counts and any errors that occurred

Returned Fields:
integer success_count Number of email addresses that were succesfully added/updated
integer error_count Number of email addresses that failed during addition/updating
array errors Array of error structs. Each error struct will contain "code", "message", and "email"

Examples (1)

[1] mcapi_listBatchUnsubscribe.php

  1. <?php
  2. /**
  3. This Example shows how to run a Batch Unsubscribe on a List using the MCAPI.php
  4. class and do some basic error checking or handle the return values.
  5. **/
  6. // Include the MailChimp API code. Do Not Edit This!
  7. include('inc/MCAPI.class.php');
  8. include('config.inc'); //username & pass
  9.  
  10. // Connect to the MailChimp server with the user's credentials.
  11. $api = new MCAPI($mailChimpUser, $mailChimpPass);
  12. $emails = array('INVALID01@mailchimp.com','INVALID02@mailchimp.com');
  13. $delete = false; //don't completely remove the emails
  14. $bye = true; // yes, send a goodbye email
  15. $notify = false; // no, don't tell me I did this
  16.  
  17. $vals = $api->listBatchUnsubscribe($id, $emails, $delete, $bye, $notify);
  18.  
  19. if (!$vals){
  20. // an api error occurred
  21. echo "code:".$api->errorCode."\n";
  22. echo "msg :".$api->errorMessage."\n";
  23. } else {
  24. echo "success:".$vals['success_count']."\n";
  25. echo "errors:".$vals['error_count']."\n";
  26. foreach($vals['errors'] as $val){
  27. echo $val['email_address']. " failed\n";
  28. echo "code:".$val['code']."\n";
  29. echo "msg :".$val['message']."\n";
  30. }
  31. }
  32. ?>
  33.  
  34.  
  35.  
Add New Note User Contributed Notes
listBatchUnsubscribe
No notes, yet... Will you be the first??

Email Marketing Resources  |   Free HTML Email Templates  |   Partners  |  Find an Expert  |   Add-ons  |   API  |   Plugins  |   Blog  |  Demos  |  Surveys  |   Webinars  |   Subscribe to our free Email Marketing Tips Newsletter

New Features:  RSS to Email  |   A/B Split Testing Emails  |   Google Analytics Integration  |   Segmentation

Truste Certified Privacy Click to verify BBB accreditation and to see a BBB report ESPC Members MAAWG Email Experience Council Members HACKER SAFE certified sites prevent over 99.9% of hacker crime.
WebAward Winner W3 Award Webby Award Nominee As featured on MSNBC's Your Business Program