listBatchUnsubscribe()

Emails from the selected list are deleted. Array of recipients’ emails with additional parameters are passed, which determine whether a message/notification about email removal will or will not be sent to this particular email.

listBatchUnsubscribe(string $id, array $emails, boolean $delete_member, boolean $send_goodbye, boolean $send_notify) : struct

Input parameters
  • id - list ID
  • emails - array of emails
  • 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 false.

Information obtained


Array consisting of:

  • success_count - number of successfully removed emails
  • error_count - number of unsuccessfully removed emails
  • errors - array of error messages about each email. Each error message is represented as an array consisting of fields:
    • code - error code
    • message - error message
    • email - email address that raised error

Examples

mgapi_listBatchUnsubscribe.php
listBatchUnsubscribe($id, $emails, $delete_member, $send_goodbye, $send_notify);
 
header("Content-Type: text/plain");
if ($api->errorCode) {
    echo "Unable to load listBatchUnsubscribe()!\n";
    echo "\tCode=" . $api->errorCode . "\n";
    echo "\tMsg=" . $api->errorMessage . "\n";
} else {
    echo "success:" . $retval['success_count'] . "\n";
    echo "errors:" . $retval['error_count'] . "\n";
    foreach ($retval['errors'] as $val) {
        echo "\t*" . $val['email'] . " failed\n";
        echo "\tcode:" . $val['code'] . "\n";
        echo "\tmsg :" . $val['message'] . "\n\n";
    }
}
xml-rpc_listBatchUnsubscribe.php
 new xmlrpcval($apikey),
                    'id' => new xmlrpcval($listId),
                    'emails' => php_xmlrpc_encode(array($my_email, $boss_man_email)),
                    'delete_member' => new xmlrpcval(false),
                    'send_goodbye' => new xmlrpcval(true),
                    'send_notify' => new xmlrpcval(false)
                ),
                'struct');
$f = new xmlrpcmsg('listBatchUnsubscribe', 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 "success:" . $retval['success_count'] . "\n";
    echo "errors:" . $retval['error_count'] . "\n";
    foreach ($retval['errors'] as $val) {
        echo "\t*" . $val['email'] . " failed\n";
        echo "\tcode:" . $val['code'] . "\n";
        echo "\tmsg :" . $val['message'] . "\n\n";
    }
} else {
    echo "Unable to load listBatchUnsubscribe()!";
    echo "\tCode=" . $r->faultCode() . "\n";
    echo "\tMsg=" . $r->faultString() . "\n";
}
mgapi_listBatchUnsubscribe.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;
emails = [my_email, boss_man_email]
delete_member = False
send_goodbye = True
send_notify = False
 
retval = api.listBatchUnsubscribe(id, emails, delete_member, send_goodbye, send_notify)
if api.errorCode:
    print "Unable to load listBatchUnsubscribe()!"
    print "\tCode=", api.errorCode
    print "\tMsg=", api.errorMessage
else:
    print "success:", retval['success_count']
    print "errors:", retval['error_count']
    for val in retval['errors']:
        print "\t*", val['email'], " failed"
        print "\tcode:", val['code']
        print "\tmsg :", val['message']

© 2010-2017 Mailigen. All rights reserved.