Playbook: mail domains and mailboxes
MZPanel runs one mail host per workspace: a server with Postfix, Dovecot, OpenDKIM, Rspamd/ClamAV and the box webmail. Domains and mailboxes are job kinds on that host. The host choice and the sending providers are control-plane settings.
Token: operate for domains, mailboxes and aliases. Installing or uninstalling the
stack and choosing the host need full. Deleting domains or mailboxes needs full +
data:delete. Reading or sending messages needs mail:read, mail:send or
mail:modify, optionally narrowed with a mailScope allowlist (see
Tokens, levels & scopes).
1. Choose and install the mail host
Section titled “1. Choose and install the mail host”mail_settings_getshows the current host server and primary login domain.mail_settings_set {body: {hostServerId: <server UUID>, primaryLoginDomain: "mail.example.com"}}(full).- On that server, run
jobs_create {id, body: {type: "mail.preflight"}}(read) to check readiness (checks[]:port25,rdns,blacklist,inbound_ports— the last lists firewall-blocked mail ports inblocked[]; open them withsecurity.fw{op: "add", port, proto: "tcp", action: "allow", noRevert: true}), then{type: "mail.install"}(full) and polljobs_get. - Set the mail hostname:
mail.hostname-set {hostname: "mail.example.com", cert: true}. - Verify:
jobs_create mail.statusorservers_inventory {id, kind: "mail"}.
2. Add a domain and mailboxes
Section titled “2. Add a domain and mailboxes”All of these are jobs_create on the mail host:
| Need | Job kind (body) |
|---|---|
| Add a mail domain | mail.domain-add {domain} |
| Add a mailbox | mail.mailbox-add {address, password?, name?, title?, quotaMb?, invite?, welcome?} (password is required unless invite: true) |
| Change a password or quota | mail.mailbox-passwd {address, password} · mail.mailbox-quota {address, quotaMb} |
| Alias | mail.alias-set {address, targets} · remove: mail.alias-del |
| Forward a mailbox | mail.mailbox-forward {address, to?, keep?} |
| Catch-all | mail.catchall-set {domain, target?} |
| Groups and shared mailboxes | mail.group-set · mail.shared-set (read jobs_schema for the fields) |
| Suspend or offboard | mail.mailbox-suspend · mail.mailbox-offboard (full + data:delete) |
| Remove | mail.mailbox-del · mail.domain-del (full + data:delete) |
The fleet-wide view is servers_mail_all, which lists domains, mailboxes and aliases on
every server.
3. DNS for deliverability
Section titled “3. DNS for deliverability”The domain needs MX, SPF, DKIM and DMARC records that point at the mail host. The
dashboard Mail page (/mail) shows the exact values. Publish them in a connected
zone with dns_records_create (see DNS, TLS and SSL), then
check with jobs_create mail.preflight and dns.lookup.
Sending through a provider (better inbox placement, or when port 25 is blocked):
- Cloudflare Email Sending:
mail_cf_sending_setup {domain}→mail_cf_sending_apply {domain, body: {serverId: <mail host>, token}}(full;tokenis a separate Cloudflare token with only Email Sending: Edit, and the server must be online). - Resend or Amazon SES:
mail_providers_create(full+webhooks:admin) →mail_provider_domain_add {id, body: {domain}}(publishes DKIM/SPF to Cloudflare) →mail_provider_domain_checkuntil verified →mail_provider_apply {id, body: {serverId: <mail host>}}. - Plain SMTP relay on the box:
mail.send-set {enabled, relayHost, relayPort, relayUser, relayPass}. ArelayPass(or thepassofmail.routes-smtp) is sealed to the server, never put on the job argv, so it needs agent 0.2.157+:409 agent_update_requiredmeans runagent_updatefirst;409 server_key_missingmeans wait for the agent to reconnect. - The same applies, from agent 0.2.161, to every other credential you hand a mail or
database job: the
passwordofmail.mailbox-add/mail.mailbox-passwd, thepassofmail.import,db.create,db.user-createanddb.user-passwd, thetokenofmail.send-cfandmail_cf_sending_apply, and the provider key ofmail_providers_create. They are sealed to the server, soargsand the audit log never show them; on an older agent these calls answer409 agent_update_required(details.required: "0.2.161") instead of running. A mailbox invite and a DB user whose password the server generates need no update.
Forward-only domains (no mailboxes) can use Cloudflare Email Routing instead:
mail_cf_enable {domain} → mail_cf_destination_add → mail_cf_rule_create {domain, body: {address, destinations}}.
4. Test and monitor
Section titled “4. Test and monitor”mail.test-send {to, from?}sends a test message.- Send routes (primary + fallbacks):
mail.routes-get(order, what is set up, per-route stats,spf_needed) →mail.routes-set {routes: ["direct","cloudflare","resend"]}(primary first; each route must be set up already: Cloudflare/Resend/SES via the tools above, a custom relay viamail.routes-smtp {host, port?, user?, pass?, tls?}).mail.routes-test {kind, to, from?}sends through ONE route and returns{ok, class, reply, ms}(ok:falseis a refusal, not a job failure). When a route refuses for its own reason the server tries the next; an unknown recipient stops it. mail.delivery-log {hours?, status?, q?, limit?}shows recent deliveries (sent, deferred, bounced, rejected).mail.queue/mail.flushshow and flush the queue (mail.queue-delneedsdata:delete).mail.sent-statsandmail.dmarc-reportreport on volume and DMARC.
5. Read and send as a mailbox
Section titled “5. Read and send as a mailbox”With a token that has the mail scopes:
mail_folders {serverId, address}andmail_messages_list {serverId, address, query: {folder?, q?, scope?}}(mail:read).mail_message_get {serverId, address, uid, query: {folder}}andmail_attachment_get(mail:read).mail_draft_savesaves a draft for a person to review (mail:read).mail_message_sendsends from that mailbox’s own address (full+mail:send). Confirm with the human first.mail_messages_modify {serverId, address, action: flag|move|delete, body}(mail:modify).
Not available to tokens
Section titled “Not available to tokens”Webmail sign-in links (mail.webmail-login), webmail rollout (mail.webmail-update)
and mailbox API keys (mail.apikey-*) are dashboard-only.