Skip to content

mattmarcum/mxoute-manager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MXroute Manager

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.

What it does

  • 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

Prerequisites

API credentials

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

Installation

git clone https://github.com/mattmarcum/mxroute-manager.git
cd mxroute-manager

python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

Configuration

Initialize the .env file:

python mxroute_manager.py init

This 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_key

Verify both API connections:

python mxroute_manager.py test

Usage

Add a domain

The typical workflow — adds the domain to MXroute and configures all DNS records in Cloudflare:

python mxroute_manager.py domain add example.com

This will:

  1. Fetch your account's verification key from MXroute
  2. Add a verification TXT record to Cloudflare
  3. Add the domain to MXroute (with retries while DNS propagates)
  4. 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.com

Pre-stage domain verification

If 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

Manage email accounts

# 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

DNS management

# 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

Other commands

# 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 test

Bitwarden integration

MXroute Manager can optionally use Bitwarden (or Vaultwarden) to generate and store email passwords, and to pull API credentials from your vault.

Password generation and storage

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 --bw

Pull API credentials from vault

Instead 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 entry

The 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.

Setup

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_password

Troubleshooting

Verbose error output

Set VERBOSE=1 to see full HTTP response details when API calls fail:

VERBOSE=1 python mxroute_manager.py domain add example.com

Or add VERBOSE=true to your .env file.

Domain verification fails

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.com

DKIM not available

DKIM 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.com

How it works

The 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.

License

MIT

About

mxroute.com management tool with cloudflare dns and bitwarden integrations

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages