From 7cbe8b601d000b33760511081585f22b6e0621a5 Mon Sep 17 00:00:00 2001 From: Thomas Kramer Date: Sun, 16 Apr 2023 12:21:28 +0200 Subject: [PATCH] Mailbox create --- createmb.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100755 createmb.py 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}") +