« Back to Documentation Overview

listUnsubscribe – v1.1

 listUnsubscribe(string apikey, string id, string email_address, boolean delete_member, boolean send_goodbye, boolean send_notify)

Unsubscribe the given email address from the list

List Related
apikey a valid API Key for your user account. Get by calling Get by visiting your API dashboard
id the list id to connect to. Get by calling lists()
email_address the email address 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 address, defaults to true
send_notify flag to send the unsubscribe notification email to the address defined in the list email notification settings, defaults to true
boolean true on success, false on failure. When using MCAPI.class.php, the value can be tested and error messages pulled from the MCAPI object (see below)

Examples (2)

download example code

[1] mcapi_listUnsubscribe.php

  1. <?php
  2. /**
  3. This Example shows how to pull the Info for a Member of a List using the MCAPI.php
  4. class and do some basic error checking.
  5. **/
  6. require_once 'inc/MCAPI.class.php';
  7. require_once 'inc/config.inc.php'; //contains apikey
  9. $api = new MCAPI($apikey);
  11. $retval = $api->listUnsubscribe( $listId,$my_email);
  12. if ($api->errorCode){
  13. echo "Unable to load listUnsubscribe()!\n";
  14. echo "\tCode=".$api->errorCode."\n";
  15. echo "\tMsg=".$api->errorMessage."\n";
  16. } else {
  17. echo "Returned: ".$retval."\n";
  18. }

[2] xml-rpc_listUnsubscribe.php

  1. <?php
  2. /**
  3. This Example shows how to Unsubscribe a member from a List using XML-RPC.
  4. Note that we are using the PEAR XML-RPC client and recommend others do as well.
  5. **/
  6. require_once 'XML/RPC2/Client.php';
  7. require_once 'inc/config.inc.php';
  8. try {
  9. $client = XML_RPC2_Client::create($apiUrl);
  11. $result = $client->listUnsubscribe($apikey, $listId, $my_email,false, false, false);
  12. echo "SUCCESS!\n";
  13. echo "Returned: ".$result."\n";
  14. } catch (XML_RPC2_FaultException $e){
  15. echo "ERROR!!!!\n";
  16. echo $e->getFaultCode()." : ".$e->getFaultString()."\n";
  17. }
  18. ?>