Skip to content

feat: server-side filtering, field selection, and additional envelope fields for mail list #9

@Juan-de-Costa-Rica

Description

@Juan-de-Costa-Rica

I've been using pm-cli heavily for automated email processing and have run into a few limitations with mail list that I'd like to propose fixing:

Server-side filtering: The --unread flag currently fetches N messages and filters client-side, so you often get back fewer results than the limit. Switching to IMAP SEARCH UNSEEN would return the right count. I'd also like to add --flagged (SEARCH FLAGGED). I use starred messages as a workflow signal and currently have to pull 200 messages and filter for flagged==true in a script.

Missing envelope fields: mail list only exposes the display name in from, which drops the actual email address when a display name is present. This makes it impossible to match on sender domain without an extra mail read call per message. I'd like to add from_address, to, message_id, and in_reply_to. All four are already in the IMAP ENVELOPE response, so there's zero additional fetch cost. in_reply_to is useful for reconstructing reply chains from list output without per-message reads.

Field selection: For consumers that only need a few fields per message, the full JSON envelope is wasteful. I'm proposing --fields (comma-separated list of fields to include in JSON output) and --compact (bare JSON array instead of the wrapper object). These only affect --json mode; text output is unchanged.

The implementation refactors ListMessages to accept a ListOptions struct instead of positional parameters, which makes it cleaner to extend. I can split this into smaller PRs if preferred.

Branch: feat/mail-list-enhancements

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