Mail Commands
Mail commands live under broodnet mail. All commands connect to your mailbox over IMAP or SMTP using credentials stored in your local config.
$ mail inbox command
Section titled “$ mail inbox ”broodnet mail inbox lists messages in INBOX with optional pagination, sort order, and flag filters. By default, messages are returned most-recent first.
Parameters
Section titled “Parameters”| Flag | Default | Description |
|---|---|---|
--limit <number> | 20 | Number of messages to fetch. Must be a positive integer. |
--offset <number> | 0 | Number of matching messages to skip. By default, the newest. Used with --limit to page through results. |
--sort <direction> | newest | Sort order for the listing. Allowed values: newest, oldest. |
--unread | — | Show only unread messages. |
--read / --seen | — | Show only read messages. |
--important / --flagged | — | Show only messages the user has marked as important. |
--answered | — | Show only messages that have been answered. |
--unanswered | — | Show only messages that have not been answered. |
--mailbox <address> | active mailbox | Mailbox address to use when multiple are configured. |
--json | — | Print a structured JSON envelope with the full listing (messages, total, pagination, filters, sort) as data. |
Filters combine with AND — e.g. --unread --important returns messages that are both unread and important. Contradictory pairs (such as --unread --read or --answered --unanswered) are rejected before any server call. Invalid sort values are also rejected before any server call.
Pagination
Section titled “Pagination”Use --offset with --limit to page through results. With the default --sort=newest, pages are counted from the most recent matching message. With --sort=oldest, pages are counted from the oldest matching message.
# First page of 20 (default)broodnet mail inbox
# Second page of 20broodnet mail inbox --limit=20 --offset=20
# First page from oldest to newestbroodnet mail inbox --sort=oldest
# Third page of 50broodnet mail inbox --limit=50 --offset=100Filters are applied before pagination, so --offset advances through the filtered set in the selected sort direction. If --offset lands past the last match, the command returns an empty result without error.
Output
Section titled “Output”In interactive terminals, the default output is a table preceded by a summary line showing the current page range, the total number of matching messages, and any active filters.
showing 1-20 of 142 · filters: unread, important
UID FLAGS FROM SUBJECT DATE...The summary adapts to the result:
inbox is empty— no messages at all and no filters activeno messages match · filters: unread— filters are active but nothing matchesshowing 0 of 42 · offset 100 is past end—--offsetlanded past the last match
| Column | Description |
|---|---|
UID | Stable message identifier used by mail open, mail mark, and mail delete |
FLAGS | ● unseen · ○ seen · ↩ answered · ★ flagged · ⤴ forwarded |
FROM | Sender |
SUBJECT | Subject line |
DATE | Message date |
JSON output
Section titled “JSON output”With --json, data is the full listing envelope so callers can drive pagination and surface totals without re-parsing the table:
messages— page of message summaries (uid,flags,from,subject,date)total— total number of messages matching the active filters (before pagination)limit— page size used for this listingoffset— offset used for this listingsort— sort direction applied to the listing:newestoroldestfilters— the filter set the server applied, e.g.{ "seen": false, "flagged": true }. Empty object means no filters were applied.
# Default: latest 20 messagesbroodnet mail inbox
# Larger pagebroodnet mail inbox --limit=50
# Paginate: second page of 20broodnet mail inbox --limit=20 --offset=20
# Oldest firstbroodnet mail inbox --sort=oldest
# Only unread messagesbroodnet mail inbox --unread
# Only important (flagged) messagesbroodnet mail inbox --important
# Unread AND importantbroodnet mail inbox --unread --important
# Unanswered messages, as JSONbroodnet mail inbox --unanswered --json$ mail open command
Section titled “$ mail open ”broodnet mail open <uid> fetches a message from INBOX by its UID, marks it as read, and prints it.
If the requested UID does not exist, the command exits non-zero with error: message <uid> not found. In --json mode, the error envelope uses code: "NOT_FOUND".
Parameters
Section titled “Parameters”| Flag | Required | Description |
|---|---|---|
<uid> | yes | Message UID — get it from broodnet mail inbox |
--mailbox <address> | no | Mailbox address to use when multiple are configured |
--raw | no | Print the full raw message source including all headers |
--json | no | Print a structured JSON envelope with the message as data |
Output modes
Section titled “Output modes”--raw and --json are independent flags: --raw controls what content is printed (parsed view vs full RFC822 source), --json controls how it is printed (plain text vs JSON envelope).
- Default — prints a compact header (from / to / subject / date, plus Cc / Bcc when present) followed by the message body. If the message has no plain-text part, the body is automatically converted from its HTML content.
--raw— prints the full raw message source as received from the server.--json— prints a JSON envelope with the parsed message asdata.--raw --json— prints a JSON envelope whosedatais{ uid, raw }. The raw RFC822 source has everything; the envelope carries only the UID alongside it.
JSON output
Section titled “JSON output”With --json (without --raw), data includes:
uid— message UIDflags—{ seen, answered, flagged, forwarded }booleansfrom— formatted primary senderto— formatted primary recipientcc/bcc/replyTo— arrays of formatted addresses; empty when the message has nonesubject— subject linedate— ISO 8601 timestampbody— plain-text body (falls back from HTML if needed)
With --raw --json, data is { uid, raw } — no parsed fields.
broodnet mail open 1234broodnet mail open 1234 --jsonbroodnet mail open 1234 --rawbroodnet mail open 1234 --raw --json$ mail watch command
Section titled “$ mail watch ”broodnet mail watch is a shortcut for mail inbox + mail open: it waits for the latest message and opens it, with output identical to broodnet mail open <uid>. Designed for flows where you trigger an email (sign up, request an OTP, invite a teammate) and want the contents on stdout without copying a UID.
How it waits
Section titled “How it waits”Two explicit timers, both fixed:
- 60-second past window. If the newest message in the inbox arrived within the last 60 seconds, the command opens it immediately.
- 60-second poll budget. Otherwise, the command checks the inbox every 3 seconds for up to 60 seconds and opens the first new message that arrives.
If nothing new arrives within the poll budget, the command exits non-zero with error: no new message arrived within 60s.
Parameters
Section titled “Parameters”| Flag | Required | Description |
|---|---|---|
--mailbox <address> | no | Mailbox address to use when multiple are configured |
--json | no | Print a structured JSON envelope with the message as data |
Output
Section titled “Output”On success, the output matches broodnet mail open <uid> exactly — compact headers followed by the text body. In interactive terminals, a one-line progress notice is written to stderr while polling (suppressed in --json mode so JSON consumers get clean stdout).
On timeout, error: no new message arrived within 60s is written to stderr and the command exits with code 1.
If a newly detected message disappears before it can be opened, the command surfaces the same not-found response as mail open: message <uid> not found with code: "NOT_FOUND" in --json mode.
# Wait for an OTP right after signing upbroodnet mail watch
# Pipe the body to another tool (e.g. extract a code)broodnet mail watch | grep -Eo '[0-9]{6}' | head -1
# Agent-friendly: JSON envelope on stdoutbroodnet mail watch --json
# Watch a specific mailboxbroodnet mail watch --mailbox=agent@example.com$ mail send command
Section titled “$ mail send ”broodnet mail send sends an email from your active mailbox over SMTP. The message body comes from --body or stdin.
Parameters
Section titled “Parameters”| Flag | Required | Description |
|---|---|---|
--to <addresses> | yes | Recipient addresses, comma-separated |
--subject <text> | no | Email subject; if omitted, the message is sent with an empty subject |
--body <text> | no | Inline message body; if omitted, reads from stdin |
--from <address> | no | Sender address — defaults to the configured from default, then the mailbox address |
--cc <addresses> | no | CC recipients, comma-separated |
--bcc <addresses> | no | BCC recipients, comma-separated |
--json | no | Print a structured JSON envelope with the send result as data |
Outbound restrictions
Section titled “Outbound restrictions”Broodnet mailboxes can only send to addresses within the same organization. External addresses are blocked at the infrastructure level and cannot be bypassed — this applies to SMTP, CLI, API, and MCP equally. See Sending Email for the full policy.
Body input
Section titled “Body input”The body is read from --body if provided. Otherwise from stdin — pipe, redirect, or heredoc all work.
# Inline bodybroodnet mail send --to=alice@example.com --body="Hello world"
# Piped bodyecho "Hello world" | broodnet mail send --to=alice@example.com
# Redirected filebroodnet mail send --to=alice@example.com --subject="Report" < report.txt
# Heredocbroodnet mail send --to=alice@example.com --subject="Hello" <<'EOF'Line oneLine twoEOF# Basicbroodnet mail send --to=alice@example.com --body="Hi!"
# With subjectbroodnet mail send --to=alice@example.com --subject="Hello" --body="Hi!"
# With CC and BCCecho "Notes" | broodnet mail send --to=alice@example.com --cc=bob@example.com --bcc=carol@example.com --subject="Notes"
# From a specific mailboxecho "Hi" | broodnet mail send --from=agent@org.broodnet.email --to=alice@example.com --subject="Hi"
# JSON outputecho "Done" | broodnet mail send --to=alice@example.com --subject="Done" --jsonJSON output
Section titled “JSON output”With --json, the result envelope includes:
messageId— server-assigned message IDto— list of accepted recipient addressesrejected— list of addresses the server rejectedsubject— the subject as sent; empty string when omitted
$ mail mark command
Section titled “$ mail mark ”broodnet mail mark <uid...> sets or clears supported IMAP flags on one or more messages without opening or deleting them.
Parameters
Section titled “Parameters”| Flag | Required | Description |
|---|---|---|
<uid...> | yes | One or more message UIDs to update |
--seen | no | Mark the selected messages as read |
--unseen | no | Mark the selected messages as unread |
--flagged | no | Mark the selected messages as flagged |
--unflagged | no | Remove the flagged marker from the selected messages |
--mailbox <address> | no | Mailbox address to use when multiple are configured |
--json | no | Print a structured JSON envelope with affected UIDs as data |
At least one flag change is required. Contradictory pairs are rejected before any server call:
--seen --unseen--flagged --unflagged
Different flag families can be combined in one call, for example --seen --flagged.
JSON output
Section titled “JSON output”With --json, data includes:
marked— the list of UIDs submitted for update
broodnet mail mark 1234 --seenbroodnet mail mark 10 11 12 --flaggedbroodnet mail mark 1234 --seen --flaggedbroodnet mail mark 1234 --unflagged --mailbox=agent@example.combroodnet mail mark 1234 --seen --json$ mail delete command
Section titled “$ mail delete ”broodnet mail delete <uid...> permanently deletes one or more messages by UID. Deletion is immediate and irreversible — messages are expunged from the server.
Parameters
Section titled “Parameters”| Flag | Required | Description |
|---|---|---|
<uid...> | yes | One or more message UIDs to delete |
--mailbox <address> | no | Mailbox address to use when multiple are configured |
--yes | no | Skip confirmation prompt. Required in non-interactive mode. |
--json | no | Print a structured JSON envelope with deleted UIDs as data |
Confirmation
Section titled “Confirmation”In interactive terminals, the command prompts for confirmation before deleting. Pass --yes to skip the prompt. In non-interactive environments (scripts, CI), --yes is required — the command will fail without it.
broodnet mail delete 1234broodnet mail delete 10 11 12broodnet mail delete 1234 --mailbox=agent@example.combroodnet mail delete 1234 --yes$ mail config command
Section titled “$ mail config ”broodnet mail config views or updates per-mailbox defaults. The only configurable default is the sender address (from), which mail send uses when --from is not passed.
Parameters
Section titled “Parameters”| Flag | Required | Description |
|---|---|---|
--from <address> | no | Set the default sender for this mailbox. Must be verified. Omit to view current config. |
--mailbox <address> | no | Mailbox to view or update (defaults to active mailbox) |
The --from value must be a valid email address or Display Name <email> format, and must be a verified sender for the mailbox. If validation fails, the command exits with an error and the config is unchanged.
Running broodnet mail config with no flags prints the current config for the active mailbox.
# View current defaultsbroodnet mail config
# Set a default senderbroodnet mail config --from='Agent Bot <agent@acme.com>'
# Set defaults for a specific mailboxbroodnet mail config --mailbox=agent@broodnet.com --from=agent@acme.com
# View as JSONbroodnet mail config --json$ mail status command
Section titled “$ mail status ”broodnet mail status shows the current state of a mailbox: its address, configured sender default, connection settings, last sync time, and live storage usage.
Parameters
Section titled “Parameters”| Flag | Required | Description |
|---|---|---|
--sync | no | Force a sync from the server before displaying |
--mailbox <address> | no | Mailbox to inspect (defaults to active mailbox) |
Storage is shown as used / quota MiB (percent%). If the server is unreachable, the command still prints the locally cached config — storage is omitted.
JSON output
Section titled “JSON output”With --json, data includes:
mailbox— the mailbox addressfrom— configured sender default, ornullhost/port— connection settingslastSync— ISO 8601 timestamp of the last sync, ornullstorage—{ quotaUsed, quota, percentInUse, unit: "MiB" }, ornullif unavailable
broodnet mail statusbroodnet mail status --syncbroodnet mail status --mailbox=agent@example.broodnet.combroodnet mail status --json