Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

syncMembers #Feature #7

Open
Dubidubiduu opened this issue Aug 19, 2021 · 0 comments
Open

syncMembers #Feature #7

Dubidubiduu opened this issue Aug 19, 2021 · 0 comments

Comments

@Dubidubiduu
Copy link

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"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant