Mailbox create

This commit is contained in:
Thomas Kramer
2023-04-16 12:21:28 +02:00
parent 7541feeadd
commit 7cbe8b601d

32
createmb.py Executable file
View File

@@ -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}")