bashmattermost

Batch processing of email invitations in Mattermost


I would like to invite a lot of people to a new Mattermost in one go. If I wanted to do this via the Mattermost web app, I should (in my case) click 300 times on "Invite People" and paste the mail addresses one by one into it. But in the documentation of Mattermost I discovered that I could also invite invites via the command line.

Mattermost Docs: Command Line Tools #platform-user-invite

sudo ./platform user invite user@example.com myteam

Now I would like to know how I can use this command most intelligently to automatically run 300 mail addresses through it. Who could show me how to do this with a bash script or something like that?


Solution

  • Where would be your source of emails? If one per line in file named foobar.txt, then maybe like this:

    while read mail; do
      sudo ./platform user invite ${mail} myteam
    done < foobar.txt