diff --git a/createmb.py b/createmb.py new file mode 100755 index 0000000..6430396 --- /dev/null +++ b/createmb.py @@ -0,0 +1,32 @@ +#!/bin/python3 + +import csv +import requests + +api_url = "https://your mailcow domain here/api/v1/add/mailbox" + +# Your API key +api_key = "API Key here" + +with open('mailboxes.csv', newline='') as csvfile: + reader = csv.DictReader(csvfile) + for row in reader: + data = { + 'local_part': row['username'], + 'domain': row['domain'], + 'password': row['password'], + 'name': row['name'], + 'quota': row['quota'] + } + + headers = { + 'Content-Type': 'application/json', + 'X-API-Key': api_key + } + response = requests.post(api_url, headers=headers, json=data) + + if response.status_code == 200: + print(f"{row['username']}@{row['domain']} successful") + else: + print(f"ERROR {row['username']}@{row['domain']}: {response.content}") +