Created
April 28, 2023 21:29
-
-
Save amanjuman/cea0445f11e24c99fae8e552d87b5067 to your computer and use it in GitHub Desktop.
MailCow Add Multiple Domain from a text file using API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Set your Mailcow API key and endpoint | |
api_key="xxx-xxx-xxxx" | |
api_endpoint="https://mcow.example.ltd/api/v1/add/domain" | |
# Set default domain values | |
aliases="400" | |
mailboxes="100" | |
defquota="1024" | |
maxquota="5120" | |
quota="512000" | |
relay_unknown_only="1" | |
gal="1" | |
active="1" | |
# Read domain names from file and add to Mailcow | |
while read -r domain; do | |
# Send POST request to add domain to Mailcow | |
curl -sSf -X 'POST' \ | |
"$api_endpoint" \ | |
-H 'accept: application/json' \ | |
-H "X-API-Key: $api_key" \ | |
-H 'Content-Type: application/json' \ | |
-d "{ | |
\"domain\": \"$domain\", | |
\"aliases\": \"$aliases\", | |
\"mailboxes\": \"$mailboxes\", | |
\"defquota\": \"$defquota\", | |
\"maxquota\": \"$maxquota\", | |
\"quota\": \"$quota\", | |
\"relay_unknown_only\": \"$relay_unknown_only\", | |
\"gal\": \"$gal\", | |
\"active\": \"$active\" | |
}" | |
echo "Added domain: $domain" | |
done < domains.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment