A command-line interface for accessing Fastmail email, calendars, events, and todos from the terminal. fastmail uses JMAP for mail workflows and CalDAV for calendar and todo workflows, and it is designed to work well for both humans and AI agents.
email,mailbox, andidentitycommands use Fastmail JMAP API tokens.calendar,event, andtodocommands use Fastmail app passwords over CalDAV.- Top-level
help <command>andschema <command>commands make the CLI discoverable without reading the source. - Machine-readable output is a core feature: use
--output json,--output jsonl,--fields,--input-json, and--dry-runwhen scripting or delegating work to an agent. - Useful aliases:
mailforemail,calforcalendar,evforevent,taskfortodo, andfolderformailbox.
# Install from source
go install github.com/shareup/fastmail@latest
# Or build locally
bin/build.sh# Store your JMAP token and optionally your CalDAV app password
fastmail auth login
# See which accounts are configured
fastmail auth status
# Discover a command and its JSON schema
fastmail help event create
fastmail schema event create
# List mailboxes and recent email
fastmail mailbox list
fastmail email list --mailbox INBOX --limit 10
# Show a specific email
fastmail email show <id>
# Send an email
fastmail email send --to alice@example.com --subject "Hello" --body "Hi there"
# Create a draft
fastmail email create --to alice@example.com --subject "Draft" --body "Work in progress"
# Body from stdin
echo "Hello from a script" | fastmail email send --to alice@example.com --subject "Piped"
# View HTML body
fastmail email show <id> --html | w3m -dump -T text/html
# Download attachments
fastmail email download <id> --all --dir ./attachments/
# Send with attachment
fastmail email send --to alice@example.com --subject "Report" --body "See attached" --attach report.pdfCalendar, event, and todo commands require a Fastmail app password:
# Add or update the app password later if needed
fastmail auth set-app-password
# List calendars and upcoming events
fastmail calendar list
fastmail event list --limit 10
# Show an event
fastmail event show <uid>
# Create an event
fastmail event create --summary "Meeting" --start "2025-07-01T10:00:00" --end "2025-07-01T11:00:00"
# Manage todos
fastmail todo list
fastmail todo create --summary "Pay invoice" --due "2026-05-12"
fastmail todo complete <uid>fastmail intentionally separates JMAP and CalDAV authentication because Fastmail does too.
Generate a token at Fastmail Settings > API Tokens.
JMAP tokens have two independent controls:
- A read-only toggle that blocks all JMAP writes.
- Capability scopes that control which JMAP APIs are available.
In practice:
urn:ietf:params:jmap:mailenables mail and mailbox access. If the read-only toggle is off, this also enables draft creation, import, moves, flags, and deletes.urn:ietf:params:jmap:submissionenables send, reply, and forward, and requires the mail capability too.- A token with mail access but without submission access can manage mail state and drafts without being able to send as the user.
Calendar, event, and todo commands use CalDAV, which requires an app password separate from the JMAP token. Generate one at Fastmail Settings > Device & App Passwords.
fastmail auth set-app-password # add app password to an existing account
fastmail auth login # or set it during loginfastmail auth login # stored under your email address by default
fastmail auth login # login again with a different email
fastmail auth status # list all accounts (* = default)
fastmail auth default work@company.com # change the default account
fastmail email list --account work@company.comCredentials are stored in ~/.fastmail/config.toml and written with 0600 permissions. If the file already has more open permissions, the CLI warns on stderr but still runs. fastmail auth login reads secrets without echoing them.
Runtime credential precedence is:
- Command-line flags such as
--token,--username, and--app-password - Environment variables such as
FASTMAIL_TOKEN,FASTMAIL_USERNAME, andFASTMAIL_APP_PASSWORD ~/.fastmail/config.toml
This matters for automation because --token and FASTMAIL_TOKEN work even when no default account has been configured yet.
Use the top-level discovery commands when you are new to the CLI or when an agent needs to inspect valid inputs safely:
fastmail help email send
fastmail help event import
fastmail help todo create
fastmail schema email create
fastmail schema event update
fastmail schema todo updateImportant automation features:
--output jsonand--output jsonlproduce machine-readable output.--fieldstrims large list and show responses to only the fields you need.--input-jsonis supported onemail create,email send,event create,event update,todo create, andtodo update.event create --input-jsonandevent update --input-jsonaccept RFC3339,YYYY-MM-DDTHH:MM:SS, andYYYY-MM-DDdate strings, and unknown JSON keys are rejected.todo create --input-jsonandtodo update --input-jsonaccept the same date strings forstartanddue, and unknown JSON keys are rejected.--dry-runpreviews mutating commands before execution. Forcalendar,event, andtodomutations, dry-run is local-only and does not require CalDAV auth. Import dry-runs parse the ICS locally.
Examples:
fastmail email list --output json --fields "id,subject,from,receivedAt"
fastmail event create --schema
fastmail event create --input-json '{"summary":"Lunch","start":"2025-07-01","end":"2025-07-01","allDay":true}' --dry-run
fastmail todo create --input-json '{"summary":"Pay invoice","due":"2026-05-12"}' --dry-runfastmail auth login|status|logout|default|set-app-password Manage authentication
fastmail mailbox list|create|delete|rename Manage mailboxes (alias: folder)
fastmail identity list List sender identities
fastmail calendar list|create|delete|rename Manage calendars (alias: cal)
fastmail event list|show|create|update|delete|import|export Manage events (alias: ev)
fastmail todo list|show|create|update|complete|delete|import|export Manage todos (alias: task)
fastmail contacts Contact command namespace (alias: contact)
fastmail email list List and filter emails (alias: mail)
fastmail email show <id> Show full email (--html for HTML body)
fastmail email count Count matching emails
fastmail email create Create a draft email
fastmail email create reply <id> Create a draft reply
fastmail email create forward <id> Create a draft forward
fastmail email send Send an email
fastmail email reply <id> Reply to an email
fastmail email forward <id> Forward an email
fastmail email move <id> <mailbox> Move email to a mailbox
fastmail email mark-read <id...> Mark as read
fastmail email mark-unread <id...> Mark as unread
fastmail email flag <id...> Flag or unflag emails
fastmail email delete <id...> Delete email (trash or permanent)
fastmail email download <id> [name] Download attachments
fastmail email upload <file...> Upload files as blobs
fastmail email import <file...> Import .eml files into a mailbox
fastmail help [command...] Show help for a command
fastmail schema <command...> Show JSON schema for a command
fastmail completion [bash|zsh|fish|powershell] Generate shell completion
fastmail version [--full] Show version information
All commands support --output / -o:
| Format | Flag | Description |
|---|---|---|
| Auto | auto |
Table for TTY, plain for pipes (default) |
| Plain | plain |
Tab-separated, one item per line |
| Table | table |
Aligned columns with header |
| JSON | json |
JSON array for collection commands; single JSON object for single-item commands |
| JSONL | jsonl |
JSON Lines (one object per line) |
auto is the default and resolves to table output on a TTY and plain output in pipes. Machine-readable output preserves native JSON types where possible, so booleans remain booleans and counts and sizes remain numbers.
Use --fields to limit output fields. --quiet is available across the CLI for terser output, but the exact effect is command-specific, so check fastmail help <command> when scripting.
bin/test.sh # Run tests
bin/format.sh # Format code
bin/build.sh # Build binarySee AGENTS.md for the repo-level agent guide and CLAUDE.md for the original project guidance that it was adapted from.