listUnsubscribe()

This function removes recipient email from existing list with all additional field values. The functionality is similar if recipient unsubscribes using unsubscribe link.

istUnsubscribe(string $id, string $email_address, boolean $delete_member, boolean $send_goodbye, boolean $send_notify) : boolean
Only active contacts can be unsubscribed or deleted. This function will not work on inactive or already unsubscribed recipients.
Input parametrs
  • id - list ID
  • email_address - email address or ID (can be found by listMemberInfo function, see Obtaining additional email information)
  • delete_member - whether recipient is deleted from existing list (true, false) (optional). Default value is false.
  • send_goodbye - whether notification is sent to the removed email (true, false) (optional).  Default value is true.
  • send_notify - whether notification is sent to sender email which is indicated for a particular list (true, false) (optional). Default value is true.

Array of merge fields. Each merge field is represented as an array that includes:

  • true, if request for removing email has succeeded

Examples

mgapi_listUnsubscribe.php
listUnsubscribe($id, $email_address, $delete_member, $send_goodbye, $send_notify);
 
header("Content-Type: text/plain");
if ($api->errorCode) {
    echo "Unable to load listUnsubscribe()!\n";
    echo "\tCode=" . $api->errorCode . "\n";
    echo "\tMsg=" . $api->errorMessage . "\n";
} else {
    echo "Returned: " . $retval . "\n";
}
xml-rpc_listUnsubscribe.php
 new xmlrpcval($apikey),
                    'id' => new xmlrpcval($listId),
                    'email_address' => new xmlrpcval($my_email),
                    'delete_member' => new xmlrpcval(false),
                    'send_goodbye' => new xmlrpcval(true),
                    'send_notify' => new xmlrpcval(false)
                ),
                'struct');
$f = new xmlrpcmsg('listUnsubscribe', array($v));
$c = new xmlrpc_client($apiUrl["path"], $apiUrl['host'], 80);
$c->setDebug($debug);
$r = &$c->send($f);
 
header("Content-Type: text/plain");
if (!$r->faultCode()) {
    $retval = php_xmlrpc_decode($r->value());
    echo "Returned: " . $retval . "\n";
} else {
    echo "Unable to load listBatchUnsubscribe()!\n";
    echo "\tCode=" . $r->faultCode() . "\n";
    echo "\tMsg=" . $r->faultString() . "\n";
}
mgapi_listUnsubscribe.py
from lib.config import * #contains apikey
from lib.MGAPI import MGAPI
 
# This Example shows how to ping using the MGAPI.php class and do some basic error checking.
 
api = MGAPI(apikey)
 
id = listId
email_address = my_email
delete_member = False
send_goodbye = True
send_notify = False
 
retval = api.listUnsubscribe(id, email_address, delete_member, send_goodbye, send_notify)
if api.errorCode:
    print "Unable to load listUnsubscribe()!"
    print "\tCode=", api.errorCode
    print "\tMsg=", api.errorMessage
else:
    print "Returned: ", retval

© 2010-2017 Mailigen. All rights reserved.