Last active
July 28, 2024 21:51
-
-
Save Suleman-Elahi/f6c00a986ea80f8fe58e20df28c97ca9 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.
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
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) |
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
Display Name | First name | Last name | password | quota | ||
---|---|---|---|---|---|---|
Ishan | Ishan | Ishan | [email protected] | Password123@ | 1024 | |
Jitu K | Jitu | Kuba | [email protected] | Password123@ | 51200 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Create the CSV file in the specified format and do not change the column names unless you know what you are doing.