Metadata-Version: 2.4
Name: maco-cli
Version: 0.4.5
Summary: An agent-friendly IMAP and SMTP command-line client
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: cryptography>=42

# Maco CLI

Maco CLI lets an Agent read, search, organize, and send mail using IMAP/SMTP, the Gmail API, or Microsoft Graph. Mailbox access is granted through Maco Mail Helper.

## Install or upgrade

Activate a virtual environment with Python 3.9 or later and run:

```sh
python -m pip install --upgrade -r https://macomail.app/cli/downloads/install.txt
maco --version
```

The Maco installation manifest pins the wheel and its SHA-256 checksum.

## Connect an Agent

Run `maco account login --start` on the machine where the Agent runs. Open the returned authorization link, verify the code, and choose the mailboxes and permissions to grant. In the same environment, run `maco account login --finish <request_id>`, followed by `maco accounts`.

## List and search messages

```sh
maco emails --account work --after 2026-11-01 --before 2026-12-01
maco search --account travel "hotel reservation OR train ticket"
maco search --account qq-profile --strict --match subject "search phrase"
```

`emails` and `search` accept both date flags. `--after` starts the range and `--before` excludes the ending date. Gmail and Outlook use UTC for the received date. IMAP uses the calendar date of the server's internal timestamp.

Each side of uppercase `OR` is a literal phrase. Double quotes within the query keep a literal `OR` together with the enclosing phrase.

Gmail search verifies indexed candidates locally, ranks subject and sender matches first, and reads bodies as needed to fill the page. Use `--native` for Gmail's indexed results directly. `--strict` verifies up to 100 candidates for any provider. Use `--match subject`, `--match from`, or `--match body` to select a field. The `matched_fields` array identifies verified fields. `strict.more_candidates` indicates that additional candidates or bodies were outside the verification performed for this result. IMAP reads use `BODY.PEEK` in a read-only session.

Outlook sends sender and subject restrictions to Microsoft Graph's search index. Graph indexes words, names, and addresses according to Outlook search syntax. Provider queries share a 30-second request budget across pages and retries. An exhausted budget returns a JSON timeout error. Outlook marks incomplete results at the 1,000-row indexed limit with `truncated`.

Read `messages[].id` and `messages[].folder` for all account types. IMAP responses also expose `emails`, `uid`, and `uidvalidity`. Pass the IMAP folder and UIDVALIDITY from the response when reading or acting on those messages.

## Configure an IMAP/SMTP proxy

Save a proxy once for this operating system user and Maco configuration directory.

```sh
maco proxy set http://127.0.0.1:8080
maco proxy show
maco proxy clear
```

`maco proxy set` without a URL saves the proxy from the current environment. Use this form when the URL includes credentials. Maco uses a private file on macOS and Linux and DPAPI on Windows. The command output shows only the proxy scheme, host, and port.

Maco checks `MACO_MAIL_PROXY`, the saved setting, then `ALL_PROXY` and `HTTPS_PROXY`. Lowercase names take precedence over conflicting uppercase names. `NO_PROXY` accepts hostname suffixes and optional ports. `MACO_MAIL_PROXY=direct` forces a direct connection for the current environment. `maco proxy set direct` saves that choice for future terminals.

With `ALL_PROXY` or `HTTPS_PROXY`, Maco uses that proxy immediately when mail DNS returns an address in `198.18.0.0/15`. Otherwise, a direct TCP or implicit TLS connectivity failure gets one proxy retry. Authentication and certificate verification errors are reported directly. The last successful route is cached per server and port for 24 hours in the Maco configuration directory.

`http://` uses CONNECT. Both `socks5://` and `socks5h://` pass the original hostname to the proxy. TLS SNI and certificate validation use the configured mail server name. Gmail API and Outlook Graph use their own HTTPS connection settings.

`maco auth check` reports `"via": "direct"` or `"via": "proxy"` for IMAP/SMTP. `maco account login --finish` reports the route for each mailbox checked during that run. When either protocol uses a proxy, the result shows `"via": "proxy"` with a `proxy` value containing its scheme, host, and port. Failed retries include the stage and reason of each attempt.

Get started at [Maco Mail Helper](https://macomail.app/cli/).
