Skip to content

syncMembers #Feature #7

Open
Open
@Dubidubiduu

Description

@Dubidubiduu

Hey there,

so I don't want/don't have the time to learn git right now but have written some lines to syncMembers. In Mailman Version 2.1.33 I do have that functionality - so here is the according function to add in api.php. Maybe someone is interested.

	 /**
	 * Sync Members to a Mailman List
	 * @param $members
	 *  Array of Members that should be synced
	 * @return
	 *  Array of Members that were successfully synced
	 */
	public function syncMembers($members) {

		$token = $this->getCSRFToken("sync");

		$response = $this->client->request('POST', $this->mailmanURL . '/members/sync', [
			'form_params' => [
				'csrf_token' => $token,
				'memberlist' => join(chr(10), $members),
				'setmemberopts_btn' => 'Änderungen speichern'
			]
		]);

		return $this->parseResultList($response->getBody());
	}

And the example to call it

$mailman = new MailmanAPI($mailManBaseURL,$adminPW);
$currentMembers = $mailman->syncMembers(["[email protected]","[email protected]"]);

Note:

  1. It only returns the newly added members, not the deleted ones.
  2. As written in my mail, I had to use "use splattner\mailmanapi;" first and then the class call is accordingly "new splattner\mailmanapi\MailmanAPI"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions