Mailbox create
This commit is contained in:
32
createmb.py
Executable file
32
createmb.py
Executable 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}")
|
||||
|
||||
Reference in New Issue
Block a user