The official command-line client for MailAfrica. Manage inbound addresses, webhooks, and sending domains, and drive sandbox, wallet, SMS, compliance, and AI auto-reply — all from your terminal.
Overview
The MailAfrica CLI is a user-side terminal client for the MailAfrica API. It covers the whole user-facing surface — inbound addresses and domains, webhooks, transactional sending from verified sending domains, sandbox testing, TZS wallet billing, SMS notifications, compliance, and the AI auto-responder — with no admin or operator commands. It is built on Go and spf13/cobra, and every list/send command can emit JSON for scripting.
go install github.com/MailAfrica/MailAfrica-CLI/cmd/mailafrica@latest
This builds mailafrica into $GOBIN (defaults to $GOPATH/bin). Alternatively, make build produces bin/mailafrica. Verify the install:
bash
mailafrica version
# mailafrica dev
Configure
Settings are resolved in precedence order: flags, then environment variables, then the config file at ~/.config/mailafrica/config.json (or $XDG_CONFIG_HOME/mailafrica/config.json). The config file is written atomically and readable only by your user (chmod 0600).
Setting
Flag
Environment
Config file
API base URL
--api-url
MAILAFRICA_API_URL
api-url
API key
--api-key
MAILAFRICA_API_KEY
api-key
Use mailafrica config path to print the config location. mailafrica config set api-url api.mailafrica.online points at a different base URL (only api-url is settable; store credentials with apikeys create --save or auth login). mailafrica config get api-key confirms a key is present — the key itself is never printed.
Authenticate
Two paths, both handled automatically on every request:
Interactive session — mailafrica auth login --identifier you@example.com. The CLI stores a refresh token in the config file, mints a JWT in-process, and auto-refreshes the token exactly once on 401.
API key — create one with mailafrica apikeys create --name prod --save, or set MAILAFRICA_API_KEY=MAIL_... for scripted/CI use. The CLI sends it as X-API-Key on every request.
From — --from-domain-id and/or --from-address to send from a verified domain; without a domain, --from-address may be a local part on the platform domain (e.g. food@mailafrica.online), otherwise the platform sender is used.
Preview a reply draft the agent would send (never sends).
--subject, --text-body
agent config is the shared source of truth with the web app. auto mode reads incoming mail and replies itself; reply-from requires a verified sending domain.
Security
Credentials — refresh tokens and API keys live only in the owner-readable config file; commands report set/not set, never values.
One-time secrets — API keys, webhook secrets, SMS keys, and sandbox credentials are shown in plaintext exactly once at creation.