Skip to content

syncMembers #Feature #7

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(["member1@domain.com","member2@domain.com"]);

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"

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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