Install
openclaw skills install emailcliInteract with your email inbox using mail-cli commands: read, search, send, reply, mark, move, delete, manage folders, drafts, and accounts via CLI.
openclaw skills install emailcliUse this skill whenever you need to interact with the user's email using the mail-cli command-line client.
# Installation (if needed)
npm install -g @laffy1309/emailcli
# Commands
mail-cli list [--folder FOLDER] [--limit N] [--account EMAIL:PROVIDER]
mail-cli read <message-id> [--thread] [--download [dir]]
mail-cli search "<query>" [--account EMAIL:PROVIDER]
mail-cli send --to <addr> --subject "<subj>" --body "<text>" [--cc <addr>] [--bcc <addr>] [--attach <file>] [--save-draft] [--draft <id>]
mail-cli reply <message-id> --to <addr> [--cc <addr>]
mail-cli mark <message-id> --read|--unread
mail-cli mark --ids 1,2,3 --read|--unread # Batch
mail-cli move <message-id> --folder "<folder>"
mail-cli move --ids 1,2,3 --folder "<folder>" # Batch
mail-cli delete <message-id>
mail-cli delete --ids 1,2,3 # Batch
mail-cli folders [--account EMAIL:PROVIDER]
mail-cli status
mail-cli drafts --list|--delete <id>
mail-cli account list|add --provider gmail|outlook|remove --account EMAIL:PROVIDER|--all
All accounts use email:provider format:
me@gmail.com:gmailme@outlook.com:outlookWhen multiple accounts exist, use --account EMAIL:PROVIDER to specify which one.
If no account is specified, the CLI uses default:gmail internally.
All commands return JSON. Parse output programmatically:
Success:
{"ok": true}
{"id": "abc123", "from": "sender@example.com", "subject": "Hello", "date": "2024-01-01T00:00:00Z"}
[{"id": "1", "from": "a@example.com"}, {"id": "2", "from": "b@example.com"}]
{"id": "...", "saved": true} // --save-draft output
{"removed": ["a@g.com:gmail", "b@outlook.com:outlook"]} // account remove --all
Error:
{"error": {"code": "NO_ACCOUNTS", "message": "No accounts configured. Run 'mail-cli account add --provider gmail' first."}}
{"error": {"code": "DRAFT_NOT_FOUND", "message": "Draft with ID 'xxx' not found"}}
{"error": {"code": "MISSING_FLAG", "message": "Either --account <id> or --all is required"}}
Batch partial failure:
{"ok": true, "failed": [{"id": "2", "error": {"code": "NOT_FOUND", "message": "Email not found"}}]}
# Default: 20 most recent inbox emails
mail-cli list
# Specific folder (Gmail uses brackets)
mail-cli list --folder "[Gmail]/Sent"
# Limit results
mail-cli list --limit 50
# Specific account
mail-cli list --account me@gmail.com:gmail
# Single email by ID (get ID from list output)
mail-cli read abc123
# Full thread
mail-cli read thread-456 --thread
# Read and download attachments to current directory
mail-cli read abc123 --download
# Read and download attachments to specific directory
mail-cli read abc123 --download ./attachments
# Gmail search syntax
mail-cli search "from:foo subject:bar has:attachment"
# Outlook KQL syntax
mail-cli search "from:foo subject:bar"
# Basic send
mail-cli send --to recipient@example.com --subject "Hello" --body "Message"
# With CC/BCC
mail-cli send --to recipient@example.com --cc other@example.com --bcc hidden@example.com --subject "Hello" --body "Message"
# From file
mail-cli send --to recipient@example.com --subject "Hello" --body-file-path message.txt
# With attachment
mail-cli send --to recipient@example.com --subject "Hello" --body "Message" --attach file.pdf
# Save as draft (don't send)
mail-cli send --to recipient@example.com --subject "Hello" --body "Message" --save-draft
# Load and send existing draft
mail-cli send --draft draft-id-123 --subject "Updated Subject"
mail-cli reply <message-id> --to sender@example.com
mail-cli reply <message-id> --to sender@example.com --cc other@example.com
# Single
mail-cli mark abc123 --read
mail-cli mark abc123 --unread
# Batch - comma-separated IDs (no spaces)
mail-cli mark --ids 1,2,3 --read
# Single
mail-cli move abc123 --folder "[Gmail]/Trash"
# Batch
mail-cli move --ids 1,2,3 --folder "[Gmail]/Archive"
# Single (moves to trash)
mail-cli delete abc123
# Batch
mail-cli delete --ids 1,2,3
# List all folders
mail-cli folders
# Mailbox status (message counts)
mail-cli status
# List all saved drafts
mail-cli drafts --list
# Delete a draft by ID
mail-cli drafts --delete draft-id-123
# Add account
mail-cli account add --provider gmail
mail-cli account add --provider outlook
# List accounts
mail-cli account list
# Remove specific account
mail-cli account remove --account me@gmail.com:gmail
# Remove ALL accounts
mail-cli account remove --all
mail-cli list to get recent emailsid, from, subject, date{"ok": true} or error--save-draft instead of sending{"id": "...", "saved": true} contains the draft ID for later usemail-cli drafts --listmail-cli send --draft <id>mail-cli search with appropriate query syntax--ids 1,2,3 format (comma-separated, no spaces)failed array to identify partial failures--download or --download <dir>downloads array with filename, path, and size for each attachmentIf you receive an error response:
error.code and error.messageNO_ACCOUNTS: Run mail-cli account add --provider gmail|outlookNOT_FOUND: The message ID doesn't exist or was already deletedINVALID_CREDENTIALS: Re-authenticate with mail-cli account remove then mail-cli account addDRAFT_NOT_FOUND: The draft ID doesn't exist or was already sent/deletedMISSING_FLAG: Required flag missing (e.g., --account or --all for account remove)CONFLICTING_FLAGS: Cannot use both --account and --all together[Gmail]/Sent, [Gmail]/Trash, [Gmail]/Archive--ids 1,2,3--to with the recipient address--account, commands default to using the first available account--save-draft and --draft are mutually exclusive in the same command