Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amit213/f2286a9327175db36a95b48c663c8bc7 to your computer and use it in GitHub Desktop.
Save amit213/f2286a9327175db36a95b48c663c8bc7 to your computer and use it in GitHub Desktop.
A script to bulk create email accounts on MXroute via API. Sleep is not really necessary so can turn off. Use the users.csv file to create the CSV file with information of user to be created, quota must be given in MB. Just replace your username, password, server URL and good to go.
import requests
import csv
import time
server_login = 'YourUserName'
server_pass = 'YourPassword/LoginKey'
endpoint_url = 'AddSevrerURLHereWithPort' + '/CMD_EMAIL_POP' #Change the first part to he URL of the server you recoeved after sign up.
headers={"Content-Type": "application/x-www-form-urlencoded",}
data_template = '{"user":"%s","passwd2":"%s","passwd":"%s","quota":"%s","limit":"7200","domain":"%s","json":"yes","action":"create"}'
with open('users.csv', newline='\n') as csvfile:
reader = csv.DictReader(csvfile)
for row in reader:
name = row['email'].split('@')[0].lower()
domain = row['email'].split('@')[1].lower()
password = row['password']
quota = row['quota']
data = data_template % (name, password, password, quota, domain)
response = requests.post(
endpoint_url,
headers=headers,
auth=(server_login, server_pass),
data=data,
timeout=5
)
print("Status: ",response.status_code," User ", name, " created !!")
time.sleep(2)
Display Name First name Last name email password quota
Ishan Ishan Ishan Ishan@example.com Password123@ 1024
Jitu K Jitu Kuba jitu.kb@example.com Password123@ 51200
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment