A CLI tool that automates MXroute email hosting management with Cloudflare DNS record setup. Add domains, create email accounts, and configure DNS records in a single workflow.
- Domain management — Add/remove domains on MXroute with automatic ownership verification
- DNS automation — Creates MX, SPF, DMARC, DKIM, and verification TXT records in Cloudflare
- Email accounts — Create, remove, and manage email accounts and passwords
- Bitwarden integration — Optionally generate passwords and store credentials in a Bitwarden/Vaultwarden vault
- Python 3.10+
- An MXroute hosting account
- A Cloudflare account managing DNS for your domains
- (Optional) Bitwarden CLI (
bw) for password management
| Credential | Where to get it |
|---|---|
| Cloudflare API Token | dash.cloudflare.com/profile/api-tokens — needs Zone:DNS:Edit and Zone:Zone:Read permissions |
| MXroute Server | From your MXroute welcome email (e.g., eagle.mxlogin.com) |
| MXroute Username | Your DirectAdmin username |
| MXroute API Key | panel.mxroute.com/api-keys.php |
git clone https://github.com/mattmarcum/mxroute-manager.git
cd mxroute-manager
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txtInitialize the .env file:
python mxroute_manager.py initThis creates .env from the template with restricted permissions (600). Edit it with your credentials:
# Required
CLOUDFLARE_API_TOKEN=your_token
MXROUTE_SERVER=eagle.mxlogin.com
MXROUTE_USERNAME=your_username
MXROUTE_API_KEY=your_api_keyVerify both API connections:
python mxroute_manager.py testThe typical workflow — adds the domain to MXroute and configures all DNS records in Cloudflare:
python mxroute_manager.py domain add example.comThis will:
- Fetch your account's verification key from MXroute
- Add a verification TXT record to Cloudflare
- Add the domain to MXroute (with retries while DNS propagates)
- Set up MX, SPF, DMARC, DKIM, and verification records in Cloudflare
To add a domain without touching DNS:
python mxroute_manager.py domain add --no-setup-dns example.comIf you want to add the verification TXT record ahead of time (useful if you know DNS propagation will be slow):
python mxroute_manager.py domain verify example.com
# ... wait for DNS to propagate ...
python mxroute_manager.py domain add example.com# Create an account (prompts for password)
python mxroute_manager.py email add example.com alice
# Create with a specific password
python mxroute_manager.py email add example.com alice -p
# List accounts
python mxroute_manager.py email list example.com
# Change password
python mxroute_manager.py email passwd example.com alice
# Set quota (in MB, 0 for unlimited)
python mxroute_manager.py email quota example.com alice 500
# Remove an account
python mxroute_manager.py email remove example.com alice# Show raw DNS config from MXroute API
python mxroute_manager.py dns info example.com
# Set up all DNS records
python mxroute_manager.py dns setup example.com
# Verify DNS is correctly configured
python mxroute_manager.py dns verify example.com
# Fetch and add DKIM record
python mxroute_manager.py dns setup-dkim example.com# List all domains
python mxroute_manager.py domain list
# Remove a domain
python mxroute_manager.py domain remove example.com
# Test API connections
python mxroute_manager.py testMXroute Manager can optionally use Bitwarden (or Vaultwarden) to generate and store email passwords, and to pull API credentials from your vault.
When creating or changing email passwords, use the --bw flag to auto-generate a strong password and save it to your vault:
python mxroute_manager.py email add example.com alice --bw
python mxroute_manager.py email passwd example.com alice --bwInstead of storing API keys in .env, you can store them in Bitwarden and have the CLI pull them at runtime. Add these to your .env:
USE_BW=true
CLOUDFLARE_BW_ENTRY=MXroute Cloudflare Token # Name of the vault entry
MXROUTE_BW_ENTRY=MXroute API # Name of the vault entryThe Cloudflare entry's password field should contain the API token. The MXroute entry should have the username and API key in the login username/password fields.
Requires the bw CLI installed and logged in:
# Install: https://bitwarden.com/help/cli/
bw login
# Optional: set master password in .env to skip the unlock prompt
# BW_PASSWORD=your_master_passwordSet VERBOSE=1 to see full HTTP response details when API calls fail:
VERBOSE=1 python mxroute_manager.py domain add example.comOr add VERBOSE=true to your .env file.
If domain add times out waiting for verification, the TXT record was already added to Cloudflare. Wait a few minutes for DNS propagation and retry:
python mxroute_manager.py domain add example.comDKIM keys may not be immediately available after adding a domain. The setup will skip DKIM and you can add it later:
python mxroute_manager.py dns setup-dkim example.comThe tool coordinates two APIs:
- MXroute API (
api.mxroute.com) — Domain and email account CRUD, DNS configuration retrieval, DKIM keys - Cloudflare API — DNS record management via the official Python SDK
DNS records are never hardcoded. The MXroute API returns the exact MX hostnames, SPF values, and DKIM keys for your server, which are then passed to Cloudflare. All DNS operations are idempotent — safe to re-run without creating duplicates.
MIT