System Administrator Documentation

This guide explains how to manage user quotas and view server statistics using madmail commands.

💡 Tip: All these operations can also be performed through the Web Admin Interface at /admin/ — no command line required.

Quota Management

You can manage user storage quotas using the madmail imap-acct quota subcommands.

View User Quota

Display the used space and maximum allowance for a specific user.

madmail imap-acct quota get [email protected]

Set User Quota

Set a custom storage limit for a user (e.g., 1GB, 500MB, or 10KB).

madmail imap-acct quota set [email protected] 1GB

Reset User Quota

Remove the user's custom quota and revert to the system default. The user's account creation date is preserved.

madmail imap-acct quota reset [email protected]

Set System-Wide Default Quota

Set the default storage limit for all users without a custom quota. This value is stored in the database and takes priority over the madmail.conf setting.

madmail imap-acct quota set-default 2GB

List All Quotas

Display all users with their used space and quota limits. The list shows whether each user's quota is custom or inherited from the system default.

madmail imap-acct quota list

Maintenance & Cleanup

Commands for managing server load and freeing space by removing user data.

Purge Send Queue

Remove all pending messages in the send queue related to a specific user (sender or recipient). Useful for clearing queue jams caused by spam or large messages.

madmail queue purge [email protected]

Purge IMAP Messages for a User

Delete all emails for a user from all mailboxes (Inbox, Sent, etc.) without deleting the account or quota settings. Useful for quickly freeing disk space.

madmail imap-acct purge-msgs [email protected]

Purge All Messages for All Users

Delete all emails across the entire server for all users. This clears all email data while keeping user accounts, passwords, and quotas intact.

madmail imap-acct purge-all

Purge All Read Messages

Delete all emails marked as read (Seen) across the entire server. New unread messages are preserved. Helps optimize space without losing new messages.

madmail imap-acct purge-read [--yes]

Prune Old Unread Messages

Delete unread messages older than the specified duration (e.g., 30 days). Useful for cleaning up old emails that users never opened.

madmail imap-acct prune-unread 720h [--yes]

Registration Management

You can open or close new user registration. When closed, only users with existing accounts can log in.

Open Registration

madmail creds registration open

Close Registration

madmail creds registration close

View Current Status

madmail creds registration status

Just-In-Time (JIT) Registration

JIT registration allows the server to automatically create user accounts on the first login attempt. You can manage this feature independently of the overall registration setting.

Enable JIT Registration

When enabled, accounts are automatically created on the first login or when the first email is received.

madmail creds jit enable

Disable JIT Registration

When disabled, accounts can only be created via the API (web interface) and login with unregistered credentials is rejected.

madmail creds jit disable

View JIT Status

madmail creds jit status

Account commands (madmail accounts)

These subcommands open your madmail.conf and talk to the on-disk databases directly (they do not require the server to be stopped). Use --cfg-block and --storage-cfg-block if your auth or IMAP blocks are not local_authdb / local_mailboxes.

Status and per-user info

madmail accounts status madmail accounts info [email protected]

Create login + IMAP mailbox

Creates credentials and an IMAP storage account (same end result as the admin panel random user).

madmail accounts create [email protected] madmail accounts create-random [--json-only]

Remove or ban

Deletes password row, removes mail storage, and blocklists the address (same as admin delete). ban accepts an optional reason as a second argument.

madmail accounts delete [email protected] [--yes] madmail accounts ban [email protected] ["reason"] [--yes]

After CLI changes while the server is running

The daemon keeps in-memory copies of credentials and quotas for speed. If you used CLI tools against the live database, call POST /admin/cache/reload once (same admin token as other API calls) so the running process re-reads those tables. See the Admin API docs for the exact JSON envelope.

Call Server Management (TURN/STUN)

You can enable or disable the call server (TURN) for all users. When disabled, call information is not shown on the info page.

Enable Call Server

madmail creds turn on

Disable Call Server

madmail creds turn off

View Current Status

madmail creds turn status

Log Management (No-Log Policy)

You can enable or disable server logging. When disabled, no information about user activity is recorded.

Disable Logging

For user privacy and to prevent storing activity information.

madmail creds log disable

Enable Logging

madmail creds log enable

View Current Status

madmail creds log status

Website Language

You can change the language of the web interface. Supported languages: English (en), Farsi (fa), Russian (ru), Spanish (es). Changes take effect immediately without a restart.

View Current Language

madmail language

Set Language

Switch the website to a different language.

madmail language set fa

Reset to Default

Remove the database override and revert to the language configured in madmail.conf.

madmail language reset

Port & Configuration Settings

Ports and service settings (such as hostname, secret, relay IP, etc.) can be managed through the Admin API. These settings are stored in the database and take priority over the configuration file values.

Manageable Settings

To manage these settings, use the Admin API. The relevant endpoints are documented in the "Port Settings" and "Configuration Settings" sections of the API docs.

Stealth Mode

Madmail server can operate in stealth mode for enhanced security. In this mode, only essential ports remain open to the outside world.

Essential ports:

Other ports (such as 25, 143, 587, 993) can be closed via firewall for public access. Users connect to all services through the Shadowsocks proxy configured in the app, keeping your server hidden from internet scanners.

Disabling Admin API

The Admin API is enabled by default. To completely disable it via the configuration file for enhanced security, set the following option in madmail.conf under the chatmail section.

madmail.conf Setting

Set admin_token to disabled:

chatmail tls://0.0.0.0:443 { # ... other settings ... # Disable the admin API entirely: admin_token disabled }

After saving the file, restart the madmail service. This will disable all web admin panel and Admin API functionality.

DNS Cache & Address Rewriting

The internal DNS cache system allows you to redirect outgoing email routing to custom servers without changing the OS DNS settings. Rewrite rules are stored in the main program database (the storage database). Changes take effect immediately without server restart.

View All Rewrites

Display all DNS rewrite rules stored in the database.

madmail dns-cache list

Create or Edit Rewrite

Set a DNS rewrite rule. If a rule already exists for this address, it will be updated.

madmail dns-cache set LOOKUP_KEY TARGET_HOST [COMMENT]

Examples:

# Route domain emails to internal server madmail dns-cache set nine.testrun.org 10.0.0.5 "Route to staging" # Rewrite IP address madmail dns-cache set 1.1.1.1 2.2.2.2 "Redirect IP" # Route to new server during migration madmail dns-cache set example.com new-mx.example.com "Migration"

View Specific Rewrite

Display details of a DNS rewrite rule including source address, target, comments, and creation time.

madmail dns-cache get nine.testrun.org

Delete Rewrite

Remove a DNS rewrite rule. After removal, emails will be routed through normal OS DNS.

madmail dns-cache remove nine.testrun.org

How It Works

Server Statistics

View Overall Statistics

Display total storage used on the server and the number of active user accounts.

madmail imap-acct stat

Online Connection Monitoring

The madmail status command shows the real-time server status. This includes active IMAP connections, TURN relays (voice/video calls), Shadowsocks, registered users, and uptime.

View Active Connections

Display server status summary including active connections, registered users, boot time, and uptime.

madmail status

Sample output:

IMAP            connections: 27     unique IPs: 7
TURN            relays: 1
Shadowsocks     connections: 0      unique IPs: 0

Registered users:   42
Boot time:          2026-02-16 20:56:19 (up 5m 24s)

Email servers seen (since last restart):
  Connection IPs:   1
  Domain servers:   1
  IP servers:       0

View Details by Port

Use the --details (or -d) flag to see connection details broken down by port.

madmail status --details

Sample output:

PORT   PROTO   TYPE              CONNECTIONS   UNIQUE IPs
993    tcp     IMAP TLS          25            7
143    tcp     IMAP              0             0
3478   udp     TURN UDP          1 relays      -
3478   tcp     TURN TCP          0             0
8388   tcp     Shadowsocks       0             0
443    tcp     ALPN (chatmail)   3             1

Field Descriptions