A command-line interface for Fastmail, designed for automation and AI agents.
- Email operations: list, read, delete
- Masked Email: full support for Fastmail's masked email feature
- Contacts & Calendar: CalDAV and CardDAV support
- Files: WebDAV file management
- Agent-first: JSON output, exit codes, and safety mechanisms
- Safety-first:
--force,--confirm, whitelist, and dry-run modes - Interactive setup:
fastmail setupfor easy credential configuration
Download the latest release for your platform from GitHub Releases.
cargo install --git https://github.com/lutra/fastmail-CLI fastmail-clicargo install fastmail-cliRun the interactive setup command:
fastmail setupThis will prompt you for your Fastmail API token and save it to ~/.config/fastmail-cli/config.toml.
Get an API token at: https://app.fastmail.com/settings/security/integrations
fastmail mail list --limit 5# List emails
fastmail mail list --limit 10
# Read an email
fastmail mail read <email-id>
# Delete emails (with safety checks)
fastmail mail delete <id> --force# List all
fastmail masked list
# Create new
fastmail masked create https://example.com --description "Shopping site"
# Enable/disable
fastmail masked enable <id>
fastmail masked disable <id>
# Delete
fastmail masked delete <id> --force# List all contacts
fastmail contacts list
# Create a contact
fastmail contacts create "John Doe" --email "john@example.com"# List calendars
fastmail calendar list
# List events
fastmail calendar list-events <calendar-id># List files
fastmail files list
# Upload a file
fastmail files upload ./document.txt /Documents/
# Download a file
fastmail files download /Documents/report.txt ./report.txtCheck if your account supports Sharing (Principals):
fastmail sharing capabilityList all principals (users, groups, resources, locations):
fastmail sharing list-principals
# Filter by name or type
fastmail sharing list-principals --name "John" --type individualGet a specific principal:
fastmail sharing get-principal <PRINCIPAL_ID>List share notifications (permission changes):
fastmail sharing list-notifications
# Filter by object type
fastmail sharing list-notifications --object-type MailboxDismiss share notifications:
fastmail sharing dismiss-notifications --ids notification1,notification2,notification3Note: Fastmail does not currently support the JMAP Sharing Extension (RFC 9670). This implementation exists for compatibility with other JMAP providers that support sharing and collaboration features.
fastmail config allow-recipient add team@company.com
fastmail config allow-recipient list
fastmail config allow-remove remove team@company.comCredentials are stored in ~/.config/fastmail-cli/config.toml:
[auth]
token = "your-api-token"
[dav]
caldav_url = "https://caldav.fastmail.com/"
carddav_url = "https://carddav.fastmail.com/"
webdav_url = "https://www.fastmail.com/"You can also set the FASTMAIL_TOKEN environment variable as an alternative.
For CalDAV/CardDAV operations, you need an app password:
export FASTMAIL_DAV_PASSWORD="your-app-password"Generate an app password at: https://www.fastmail.com/settings/passwords
Commands output JSON by default:
{
"ok": true,
"result": [...],
"error": null,
"meta": {
"rate_limit": null,
"dry_run": false,
"operation_id": null
}
}You can force a specific output format:
# Force JSON (even in terminal)
fastmail mail list --output json
# Force human-readable (even when piped)
fastmail mail list --output human0: Success1: Transient error (retry safe)2: Permanent error (do not retry)3: Safety check failed (operation rejected)
Note: The fastmail blob commands below use the JMAP Blob Management Extension (RFC 9404), which is not supported by Fastmail.
Fastmail does support RFC 8620 upload/download URLs internally (used for email attachments), but the CLI blob commands are not currently implemented to use those URLs.
All blob commands below require RFC 9404 support and will not work with Fastmail accounts:
# These commands are NOT available on Fastmail:
fastmail blob upload document.pdf --type application/pdf
fastmail blob download <BLOB_ID> output.pdf
fastmail blob info <BLOB_ID>
fastmail blob lookup <BLOB_ID> --types Email --types Mailbox
fastmail blob capabilityThese commands are included for compatibility with other JMAP providers that support RFC 9404.
MIT