Skip to content

feat: mail batch subcommand for multi-op IMAP sessions #10

@Juan-de-Costa-Rica

Description

@Juan-de-Costa-Rica

My email triage setup applies labels, flags, and moves to 20+ messages per run. Each pm-cli call currently opens a fresh IMAP session to Proton Bridge, so a typical apply run is 5-10 separate connections with full auth round-trips. It's the dominant latency.

I'm proposing a mail batch command that reads a JSON array of operations from stdin and executes them over a single IMAP connection:

echo '[
  {"op": "label",   "uids": ["uid:123"], "label": "Important"},
  {"op": "flag",    "uids": ["uid:456"], "read": true},
  {"op": "archive", "uids": ["uid:789"]}
]' | pm-cli mail batch --json

Supported ops: label, unlabel, archive, move, flag, delete. Each op is validated before execution: unknown ops, missing required fields, and IMAP special characters in names are all caught upfront. Input is capped at 10MB via io.LimitReader. Output reports per-op success/failure, with an optional --stop-on-error flag.

Branch: feat/mail-batch. Open to feedback on the JSON schema.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions