Manage a Mailbox
Trash, restore, and purge messages, block senders, read suppression feedback, and export retained Mail.
Clean up a Mailbox, stop unwanted arrivals, and take a copy of retained correspondence. People can also archive, trash, restore, and (owners and admins) permanently delete from the dashboard; blocking senders and export use the CLI, SDK, or API.
Trash, restore, and purge
Use a message ID from mail list:
Send an empty JSON object to act on your own Mailbox, or { "mailboxId": "..." }
to target another one you're authorized for. Members can trash and restore their
own messages. Owners and admins can also select another permitted Mailbox with
--mailbox MAILBOX_ID and permanently purge content that is already in trash.
| Action | Effect |
|---|---|
| Trash | Restorable for seven days from the first trash action; repeating it doesn't extend the deadline. Still counts toward storage. |
| Restore | Returns the message to its earlier view. Never resumes sending. |
| Purge | Permanently removes trashed content and frees its body storage. Can't be undone. |
Expiry in trash also removes content and frees storage. Incoming usage isn't refunded. Trash stops further sending submissions and cancels sends that definitely hadn't started; already-started sends still need reconciliation. None of these actions can recall a sent message or refund sending usage, or remove local send records and copies that clients or recipients already have.
Success returns { "acknowledged": true }. These commands never retry
automatically. If a response is lost, check mail list, mail list --view trash,
or mail read MESSAGE_ID before deciding what to do; a missing message doesn't
prove your request succeeded, and another session may have changed it since.
Purging content that is already gone returns not_found.
Block a sender
Block an exact From address to stop retaining future mail from it:
Use --mailbox <id> only for a Mailbox you administer. Continue a listing with
--after, and restart it to include rules added before your cursor.
Blocked arrivals keep no body or attachments, use no incoming unit, and appear in
mail omissions as sender_blocked for seven days. This doesn't guarantee that
the email provider rejected or didn't charge for the message. Blocking leaves
existing content unchanged, and unblocking doesn't retrieve mail omitted earlier.
How matching works
- Supply a bare address. Domain case is normalized; external local-part case and plus aliases stay distinct.
- Matching uses one unambiguous canonical From address, never Reply-To or display names. The message's From header wins; the provider's From field is used only when the header is absent. An ambiguous or omitted From header doesn't fall back to another field.
- Blocking isn't sender authentication.
- Repeating the current state is idempotent. Opposing concurrent writes apply in commit order, so retrying an older request can change the current rule.
The dashboard shows omission reasons but can't change rules.
Provider suppression feedback
When detailed history is available, mail status and SDK getMailOperation
include receipt.suppressedAt. It records that the email provider suppressed
delivery for this operation, without identifying which recipients or marking the
whole message failed. The server stops new attempts for that operation, though
requests already running may finish. Don't create a new send to get around
suppression.
receipt.suppressedAt | Meaning |
|---|---|
| A timestamp | Suppression was recorded at that time. |
null | No suppression has been recorded. |
| Absent | The information isn't available. |
None of these is evidence of delivery. Accepted usage is unchanged, and an uncertain operation stays uncertain until independent evidence arrives. The dashboard message view shows the same observation while history is available. Incoming spam assessment isn't available; sender blocking and provider complaint feedback are separate protections.
Export retained Mail
Agents can export a retained message, its currently known thread, or a whole authorized Mailbox. Export copies the actual retained text, HTML, and attachments with their metadata. It doesn't rebuild original MIME messages, recover purged content, or claim a complete external conversation.
| Scope | Exports |
|---|---|
--scope message --message MESSAGE_ID | One message |
--scope thread --message MESSAGE_ID | The known conversation |
--scope mailbox | The whole retained Mailbox, including trash, pending preparations, and omission history |
The output must be a new directory whose parent exists. The operation file must be
outside the output, in an existing directory you own with mode 0700. Recovery
requires a POSIX filesystem.
Resume an export
The CLI first freezes an inventory, then copies the pinned content. After an interruption, repeat the same command, operation file, and output:
- Completed local bytes are checked and reused.
- Unfinished attachments are fetched again under current authorization and must match the original identity, length, and SHA-256. A purge in the meantime can prevent that.
- Export never substitutes a newer part or overwrites an existing file.
- An interrupted inventory restarts with a fresh observation checkpoint. A completed inventory isn't refreshed, so use a new operation and output to pick up new content or attachments retained later.
- If discovery stops for thread indexing or a conflict, retry the same command.
If a crash happens between creating an output or recovery path and recording its identity, the same command fails safely rather than adopting the unrecorded path. Keep existing copies and start a fresh export with a new operation file and output directory; don't edit receipts or delete files to force a retry. Bytes no longer retained at the source can't be fetched into the fresh export.
Export output
| File | Contents |
|---|---|
manifest-ATTEMPT.json | Each attempt's outcome, counters, and coverage |
record-N.json | Frozen metadata, in inventory order |
attempt-ATTEMPT-N.json | Copy results for that record |
message-ID.text, .html | Message bodies |
attachment-ID.bin | Attachment bytes |
Original filenames, content types, and display metadata stay in the metadata and never become local paths. An empty present body produces an empty file, while absent and unknown bodies stay distinct; pending and omitted parts are listed explicitly. Keep the hidden staging files and private operation storage with the output until you no longer need recovery. Download grants are never saved.
Every export reports coverage: "non_snapshot". mailboxChanges reports changes
seen during the inventory and copy, or unknown if history can't establish
coverage. state: "partial" covers failures, missing or duplicate discovery,
pending preparations or parts, unknown body representations, and unknown change
coverage; partial results print JSON to stdout, exit nonzero, and explain on
stderr. Losing authorization stops further acquisition, so inspect stopped,
per-record results, and unattemptedRecords. Preserved omission metadata on its
own isn't a failed copy.
Export with the SDK
walkRetainedMail(auth, { mailboxId, scope }, visits) iterates inventory records
with backpressure. It yields records, not local files or attachment bytes; use
downloadMailAttachment for verified bytes. Provide a fresh asynchronous
visits.addIfNew(key) store for each traversal, and persist its opaque keys
rather than keeping them in memory for large Mailboxes. A thread's incomplete
state and per-resource issues are separate from completed enumeration, and even a
complete inventory doesn't mean its bytes were copied.