# Mars: Mail Auto Reply Service

> Source: <https://github.com/cheikh2shift/mars>
> Published: 2026-11-23 14:03:12+00:00

**Key takeaway:** MARS generates `.marc` YAML rules via OpenRouter tool calling and requires explicit user confirmation before activation, tracking per-MARC `last_uid`/`uid_validity` cursors in SQLite so incremental IMAP/POP3 sync only fetches new mail.

An open-source Go TUI and CLI for authoring, managing, and running AI-generated **MARC** (Mail Auto Reply Configuration) rules over IMAP/POP3 and SMTP with OpenRouter OAuth2 and SQLite state tracking.

**MARS** automates repetitive inbox triage and context-aware email responses without forcing you to maintain brittle mail filter syntax by hand.

You describe how you want a category of email handled in plain language; MARS sends that strategy to your chosen OpenRouter model with structured tool calling to produce a `.marc` rule file (`name`, `keywords`, `exclude_keywords`, `match_mode`, and `auto_reply_message`). You review and **confirm** or **reject** the generated configuration before it ever touches your mailbox.

Once active, MARS polls your inbox incrementally via **IMAP** or **POP3**, tracks the last fetched message cursor in **SQLite** so it never redownloads your entire mailbox, retries transient network failures with **exponential backoff**, and dispatches replies via **SMTP**—all inside an interactive terminal UI with a live bottom progress bar or headlessly from the CLI.

- **Support & SLA Triage** : Acknowledge bug reports, billing questions, or onboarding requests with ticket links and expected response windows.
- **Out-of-Office & Sabbatical Rules** : Send tailored auto-replies depending on topic (e.g., urgent production incidents vs. routine scheduling).
- **Partnership, Press & Sponsorship Routing** : Automatically direct media or vendor inquiries to the right intake form or contact.
- **Closed Listings & Waitlists** : Politely notify late applicants for closed roles, full cohorts, or expired RFPs without manual inbox cleanup.
- **Cold Outreach Filtering** : Decline unsolicited staffing, agency, or sales pitches automatically while excluding newsletters and automated notifications.

- **OpenRouter OAuth2 PKCE & Model Search** : Starts with an OpenRouter OAuth2 PKCE flow (or API key setup), followed by an interactive model picker with live search.
- **Tool-Called MARC Authoring** : Generates`.marc` configurations via OpenRouter function/tool calling (`generate_marc` ) with explicit user confirmation or rejection.
- **Per-MARC UID Tracking & SQLite Message Cache (`~/.mars/`)** :
  - `~/.mars/config.json` — OpenRouter credentials, active model, IMAP/POP3, SMTP, and retry/backoff settings.
  - `~/.mars/marcs/*.marc` — Human-readable YAML rule files.
  - `~/.mars/mars.db` — SQLite database indexing all MARC files,**per-MARC**`last_uid` /`uid_validity` cursors, and reply deduplication logs.
  - `~/.mars/cache.db` — Separate SQLite message cache storing fetched emails locally for instant offline rule evaluation and zero redundant mailbox re-downloads.
- **Incremental Sync & Exponential Backoff** : Tracks`last_uid` /`UIDL` per mailbox so subsequent runs only inspect new mail, with configurable`max_retries` ,`initial_backoff_ms` ,`max_backoff_ms` , and multiplier.
- **TUI Progress Status Bar & CLI Mode** : Visual progress bar at the bottom of the TUI during mail fetches, plus full CLI subcommands for cron jobs and servers.

Requires **Go 1.22+** (100% pure Go — no C compiler, `gcc`, or `libc6-dev` required).

```
# Resolve module checksums and run/build in pure Go mode
CGO_ENABLED=0 go mod tidy
CGO_ENABLED=0 go build -o mars ./cmd/mars

# Launch the interactive TUI (OAuth2 -> Model Picker -> Dashboard)
./mars
```

Or use the included `Makefile` (`CGO_ENABLED=0` is set automatically):

```
make tidy && make run
make test
```

**Note for Linux environments without C headers (`libc6-dev`)**: Always pass `CGO_ENABLED=0` (or run `go env -w CGO_ENABLED=0`). Every dependency in MARS (` modernc.org/sqlite`, `go-imap/v2`, `go-pop3`, `bubbletea`, `cobra`) is pure Go and requires zero CGO.

```
# Authenticate with OpenRouter via OAuth2 PKCE
./mars auth

# Generate a new .marc rule from a natural-language strategy (prompts to confirm/reject)
./mars marc generate "Acknowledge support and billing emails with a 24-hour SLA notice"

# List all MARC configurations indexed in ~/.mars/mars.db
./mars marc list

# Delete a MARC configuration file and remove it from SQLite
./mars marc delete support-and-billing-triage

# Inspect active model, mail server config, and last fetched UID cursor
./mars status

# Run one incremental IMAP/POP3 fetch + SMTP auto-reply pass
./mars sync
version: 1
name: Support & Billing Triage
slug: support-and-billing-triage
enabled: true
match_mode: any
keywords:
  - support
  - billing
  - invoice
  - bug report
exclude_keywords:
  - unsubscribe
  - mailer-daemon
reply_subject_prefix: "Re: "
auto_reply_message: |
  Thanks for reaching out. We have received your message and routed it to our
  triage queue. Typical response time is within 1 business day.
cooldown_hours: 168
Makefile                       Pure-Go (CGO_ENABLED=0) tidy/build/run/test targets
cmd/mars/main.go               Cobra CLI + Bubble Tea launcher
internal/
  auth/openrouter.go           OpenRouter OAuth2 PKCE local callback server
  config/config.go             ~/.mars/config.json & retry policy management
  mail/fetcher.go              Incremental IMAP/POP3 fetcher, SMTP sender, exponential backoff
  marc/marc.go                 .marc YAML reader/writer & keyword matcher
  openrouter/client.go         Model catalog listing & tool-called MARC generation
  store/sqlite.go              Pure-Go modernc.org/sqlite ~/.mars/mars.db index & cursors
  tui/app.go                   Bubble Tea TUI screens & bottom fetch progress bar
```

Released under the [MIT License](https://github.com/cheikh2shift/mars/blob/main/LICENSE).
