Declarative email for custom domains: plan and apply DNS, mailboxes, aliases and deliverability (SPF, DKIM, DMARC, MTA-STS) across Purelymail, Microsoft 365 and Cloudflare, audit live mail health, with an MCP server; mailctl doctor checks the install.
Declarative email configuration for custom domains. One YAML file describes the
DNS records, mailboxes, aliases, routing and deliverability policy for every
domain you own; mailctl works out what has to change, shows you, and then
changes it.
It is a single Go binary with three non-stdlib dependencies: a YAML parser,
and two small ZoolCoder modules its local admin page is built on. No daemon, no state file, no
lock — the live provider APIs are the state.
$ mailctl plan
example.com
-----------
CREATE dns MX example.com -> mailserver.purelymail.com [purelymail]
CREATE dns TXT example.com -> v=spf1 include:_spf.purelymail.com ~all
CREATE dns CNAME purelymail1._domainkey.example.com
CREATE domain add example.com [purelymail]
CREATE mailbox create [email protected] [purelymail]
9 actions
Run `mailctl apply` to make these changes.
¹ Not because mailctl declines to implement them. Microsoft Graph exposes
proxyAddresses as read-only and offers no catch-all surface, so mailctl
rejects those config blocks with an error naming the admin centre rather than
accepting them and silently doing nothing.
² An alias is an extra address on one mailbox of the same domain, so it takes
exactly one target and no trailing *. The Zoho catch-all takes one target.
³ The Admin SDK has no routing API; set catch-all under Gmail > Default routing
in the Admin console. The Google DKIM key has no API either: copy its TXT value
into mail.gworkspace.dkim.
DNS is managed in Cloudflare. Deliverability — SPF, DKIM, DMARC, MTA-STS,
TLS-RPT, BIMI — is managed for any provider combination, including merging every
provider's SPF requirement into the single TXT record RFC 7208 permits.
Install
On macOS or Linux with Homebrew:
$ brew tap zoolcoder/mailctl https://github.com/zoolcoder/mailctl
$ brew install --cask mailctl
Or download a binary for your platform from the
latest release — Linux,
macOS and Windows, amd64 and arm64, with SHA-256 checksums:
$ tar -xzf mailctl_linux_amd64.tar.gz
$ ./mailctl version
With a Go toolchain, Go 1.26 or newer:
$ go install github.com/zoolcoder/mailctl/cmd/mailctl@latest
Put it at ~/.config/mailctl/mailctl.yaml (or pass -config), store the
tokens in the macOS Keychain (or export them), and check the setup:
$ security add-generic-password -U -s mailctl -a CLOUDFLARE_API_TOKEN -w
$ security add-generic-password -U -s mailctl -a PURELYMAIL_API_TOKEN -w
$ mailctl doctor # config, credentials, APIs, DNS
$ mailctl plan # read-only
$ mailctl apply # make it so
$ mailctl audit # verify through a real resolver
Omitting passwordEnv on a mailbox makes mailctl generate the credential and
report it exactly once — when the mailbox is genuinely created, not when it is
planned. On macOS it goes to the Keychain (service mailctl, account = the
address); -secrets-out writes it to a 0600 file instead and refuses a path
that already exists.