$limit = COMMUNITY_MAIL_LIST_MEMBERS_LIMIT; $community_id = 0; $query = "\tSELECT a.* FROM `community_mailing_list_members` AS a\n\t\t\t\t\t\t\t\t\t\tJOIN `community_mailing_lists` AS b\n\t\t\t\t\t\t\t\t\t\tON a.`community_id` = b.`community_id`\n\t\t\t\t\t\t\t\t\t\tWHERE a.`member_active` < 0\n\t\t\t\t\t\t\t\t\t\tORDER BY a.`community_id` ASC"; if ($members = $db->GetAll($query)) { foreach ($members as $member) { if ($community_id != (int) $member["community_id"]) { $community_id = (int) $member["community_id"]; $list = new MailingList($community_id); $list->fetch_current_list(); $current_users = array_merge($list->current_owners, $list->current_members); } echo "Delete: " . $member["email"] . " -> " . $community_id . "<br />"; if (in_array($member["email"], $current_users)) { try { $list->remove($member["email"]); $list->base_remove_member($member["proxy_id"]); } catch (Exception $e) { echo $e->getCode() . " - " . $e->getMessage(); if ($e->getCode() == "502") { exit; } application_log("notice", "An issue was encountered while attempting to remove a user's email [" . $member["email"] . "] from a community [" . $community_id . "] mailing list. The server said: " . $e->getCode() . " - " . $e->getMessage()); } } else { $list->base_remove_member($member["proxy_id"]); application_log("notice", "An issue was encountered while attempting to remove a user's email [" . $member["email"] . "] from a community [" . $community_id . "] mailing list. The member was not present in the list."); } /** * Email limit so exit */ if (!--$limit) {