Skip to content
Projetos

Sobre

Email & Calendar CLI. Gmail, Outlook, iCloud, IMAP/SMTP and Google Calendar from your terminal. For humans & agents

Produtividade e automação

Como estes números são medidos

Crescimento medido de estrelas

em 24 h
+2
em 7 dias
+16
em 15 dias
+18
em 1 mês
Coletando histórico

Variações líquidas em períodos sobrepostos, não totais diários. Medições ausentes ficam em branco. Estrelas indicam interesse, não qualidade.

README.md

Original


zele

Email & Calendar CLI. Gmail, Outlook, iCloud, IMAP/SMTP. For you and your agents



Install

Multi-account email and calendar client supporting Google OAuth, Microsoft OAuth (Outlook / Hotmail), iCloud Mail and Calendar, IMAP/SMTP (Fastmail, any provider), free @zele.sh addresses, and your own domain on Cloudflare. SQLite cache, YAML output.

All CLI commands work with Node.js (v22.16+). The interactive TUI (zele with no subcommand) requires Bun and will auto-spawn it if available.

# with npm / npx (CLI commands only, no TUI)
npm install -g zele

# with bun (full support including TUI)
bun install -g zele

If you install via npm and run zele (the TUI), it will try to find bun in your PATH and re-spawn automatically. If bun is not installed, you'll get install instructions.

Works with Gmail, Outlook, Fastmail, Proton Mail and any IMAP/SMTP provider

Setup

Google accounts

zele login

Opens a browser for Google OAuth2. Repeat to add more accounts.

Use your own Google OAuth client

Set ZELE_CLIENT_ID and ZELE_CLIENT_SECRET to log in with a client from your own Google Cloud project:

export ZELE_CLIENT_ID=123.apps.googleusercontent.com
export ZELE_CLIENT_SECRET=your-client-secret
zele login
  • Desktop app clients work with no extra setup.
  • Web application clients need http://localhost:8089 as an authorized redirect URI.
  • Enable the Gmail API and the CalDAV API in the project.
  • Keep both variables set when you run zele. Token refresh uses the same client.

Remote / headless login (for agents)

In an agent or non-TTY shell, zele login --method google and zele login microsoft start a background daemon and return immediately. Open the printed URL, approve access, then poll:

zele login --method google
zele whoami

On a TTY, login stays in the foreground. If the browser runs on another machine, the redirect page to 127.0.0.1 will not load. Copy the full URL from the address bar and paste it into the prompt.

For password login in a non-TTY shell, pass the email and app-specific password as flags.

Outlook / Hotmail / Microsoft 365

Microsoft disabled password IMAP on Outlook.com. Use browser OAuth (XOAUTH2):

zele login microsoft
zele login microsoft --email [email protected]

This uses Thunderbird's public Microsoft client ID and a loopback callback on 127.0.0.1, same pattern as Google login.

iCloud Mail and Calendar

zele login icloud

Enter your iCloud email address and an app-specific password. Zele configures IMAP, SMTP, and CalDAV for you. Login checks all three services before saving the account.

Create the password at https://account.apple.com/ under Sign-In and Security > App-Specific Passwords. Your Apple Account must have two-factor authentication enabled. Do not use your main Apple Account password.

For non-interactive login:

zele login icloud --email [email protected] --password "xxxx-xxxx-xxxx-xxxx"

Use the same calendar commands as Google:

zele cal list --account [email protected]
zele cal events --account [email protected] --all --week

If you connected iCloud Mail with an older version, run zele login icloud again to enable calendars.

IMAP/SMTP accounts

For non-Google, non-Microsoft providers (Fastmail, Gmail with app passwords, any IMAP server):

# Fastmail
zele login imap \
  --email [email protected] \
  --imap-host imap.fastmail.com --imap-port 993 \
  --smtp-host smtp.fastmail.com --smtp-port 465 \
  --password "your-app-password"

# Gmail (app password)
zele login imap \
  --email [email protected] \
  --imap-host imap.gmail.com --imap-port 993 \
  --smtp-host smtp.gmail.com --smtp-port 465 \
  --password "your-app-password"

# IMAP-only (no sending)
zele login imap \
  --email [email protected] \
  --imap-host imap.example.com --imap-port 993 \
  --password "pass"

# Proton Mail Bridge (STARTTLS on 1143/1025, self-signed cert)
zele login imap \
  --email [email protected] \
  --imap-host 127.0.0.1 --imap-port 1143 \
  --smtp-host 127.0.0.1 --smtp-port 1025 \
  --password "<bridge-password>" \
  --no-tls --ca ~/bridge/cert.pem

Use --imap-user / --smtp-user if the login username differs from your email. Omit --smtp-host for read-only access.

For self-signed servers, prefer --ca <path> to trust a PEM certificate (Proton Bridge exports cert.pem). --insecure disables certificate verification and is unsafe. --no-tls disables implicit IMAP TLS; STARTTLS is still attempted when the server advertises it. Bridge SSL mode (implicit TLS on custom ports) needs --smtp-tls.

Free @zele.sh inboxes (receive only)

Get up to 10 free, permanent @zele.sh addresses: a real email address for you, a project, or each of your agents. They keep your mail until you delete it. They are receive-only for now; sending is planned. The owner is your @gmail.com address (other domains are not accepted, to keep bots out).

zele login zele --owner [email protected] --name tommy   # sign in + create [email protected]
zele inbox create bills                               # [email protected]
zele inbox list
zele mail list --account [email protected]
zele mail watch --account [email protected] --filter 'subject:verify' --timeout 600
zele inbox delete [email protected] --force               # the address is never reused

Sign-in sends a code to the owner Gmail. If that Gmail is already a zele account, zele reads the code from it and trashes the code email, so login needs no typing. Otherwise type the code, or pass --code.

Inboxes work like any other account: mail list, read, search (from:, to:, subject:, is:unread), watch, star, archive, trash, spam and attachment. zele logout zele removes the session and inbox accounts from this machine; inboxes and mail stay on the server.

Your own domain with Cloudflare (send and receive)

Self-host your mailbox with one command, thanks to Cloudflare OAuth. Mail storage, receiving, and sending use your Cloudflare account, not ours.

zele domain setup example.com                  # [email protected], catch-all at the zone apex
zele mail list --account example.com           # every address on the domain
zele mail list --account [email protected]     # only alice's mailbox
zele mail send --account [email protected] --to [email protected] --subject Hi --body Hello
zele mail send --account [email protected] --from [email protected] --to [email protected] --subject Invoice --body Hello

In agent or non-interactive shells, setup prints the authorization link and continues in a background daemon for up to 10 minutes. No shell backgrounding is needed. After approving, run zele domain status example.com. Status exits with code 1 while setup runs, after a failed or unfinished setup (it prints the error as last_setup), when receiving does not work, or when the domain has no local account. With no saved login, interactive terminals stay attached to setup and show its progress.

Setup signs in to Cloudflare in the browser (OAuth, no API token to copy), then creates or updates:

Resource What it does
Email Sending onboards the domain (DKIM, SPF and bounce records)
Email Routing configures receiving DNS and routes mail to the Worker
Worker zele-domain-mail stores incoming mail in R2 through an email handler, with no mailbox HTTP API or shared secret
R2 bucket zele-domain-mail one mailbox per address: <domain>/<mailbox>/<folder>/<stamp>.<index>

We do not receive or see your custom-domain emails through this architecture. The CLI calls Cloudflare directly. There is no zele-operated mail proxy or storage. Messages still travel between Cloudflare and external senders or recipients, and the CLI downloads mail to your computer to read it. An agent that runs zele can see the output you give it. This differs from the hosted @zele.sh service above.

No lock-in to zele. You own the Worker, R2 bucket, and domain routing. Mail is stored as raw MIME messages that you can download as .eml files and import into another mail tool. You can change your domain's routing to another provider. OAuth credentials stay on your computer, and you can revoke zele's access in Cloudflare. Review the open-source code before granting access. The setup command explains this before showing the OAuth link.

Requirements: an active Cloudflare DNS zone, R2 enabled in the dashboard, and Workers Paid to send to arbitrary recipients. Workers Free sends only to verified addresses. If the domain's MX records point to another mail provider (for example Google Workspace), setup stops before it changes anything, so your existing mail keeps working. Use a subdomain with no MX records instead, for example zele domain setup mail.example.com.

Each domain has one account and one mailbox per address. Received mail is filed under its SMTP envelope recipient, so a catch-all alias gets its own mailbox. --account alice@<domain> reads, sends and files Sent copies as alice, and only lists alice's R2 prefix. --account <domain>, or no --account, lists every mailbox merged newest first; zele domain status shows which mailboxes exist. Replies and forwards always go out as the message's mailbox. The default From address is hello@<domain>; --address tommy changes it. Catch-all is the default at the zone apex. Subdomains receive only --address. Use --no-catch-all to select address-only routing at the apex. Existing literal routing rules still take precedence.

zele domain setup mail.example.com --address support
zele domain setup example.com --no-catch-all --address tommy
zele domain setup example.com --receive-only  # skip sending onboarding, not a permission restriction
zele domain status example.com
zele domain list

Run zele domain setup <domain> again after a zele upgrade to update the Worker. Reruns keep the live routing mode, so address-only routing never widens to catch-all; --catch-all switches back. Keep --receive-only on reruns of receive-only domains (domain status prints the right command). Setup refuses to downgrade a newer Worker. On a second machine, run setup for a separate OAuth grant instead of copying Cloudflare credentials.

zele domain remove <domain> stops zele routing and removes the local account. Mail stays in R2 unless you pass --delete-mail. The shared Worker, bucket, DNS records, and Email Sending configuration stay.

Supported commands include list, read, search (from:, to:, subject:, deliveredto: and plain words), send, reply, forward, archive, trash, attachments, and watch. There is no unread, star, spam, draft, label, or calendar support. Read the Cloudflare mail guide for data flow, permissions, search limits, and removal details.

Account management

zele whoami         # show authenticated accounts (type, capabilities)
zele logout         # remove credentials

Use zele on another machine

Local zele state is in one SQLite file: ~/.zele/sqlite.db. It holds accounts, OAuth tokens or IMAP passwords, the zele.sh session, and mail caches. You can copy it for Google, Microsoft, IMAP, and zele.sh accounts.

Cloudflare exception: run zele domain setup <domain> separately on each machine. Cloudflare rotates refresh tokens. Two copies of the same grant can invalidate each other. Do not use the database-copy procedure below for Cloudflare accounts.

# on the machine that is logged in: make one consistent file (zele uses WAL mode)
sqlite3 ~/.zele/sqlite.db ".backup /tmp/zele.db"
scp /tmp/zele.db other-host:/tmp/zele.db && rm /tmp/zele.db

# on the other machine: install the same or a newer zele, then
mkdir -p -m 700 ~/.zele
mv /tmp/zele.db ~/.zele/sqlite.db && chmod 600 ~/.zele/sqlite.db
zele whoami

Without sqlite3, stop every zele process first and copy sqlite.db together with sqlite.db-wal if it exists. Copying sqlite.db alone can lose the latest token refresh.

Things to know:

  • The file is a password. IMAP passwords and OAuth refresh tokens are stored unencrypted. Send it over scp/ssh, never through chat, email or a synced folder. zele sets ~/.zele to 700 and the files to 600 on every start.
  • Both machines keep working. Each copy refreshes its own access tokens. Google and Microsoft refresh tokens stay valid after use, so one machine does not log out the other.
  • The copies do not sync. A login, logout or inbox create changes only that machine. Read marks are per machine too: mail reply needs a mail read of the thread on the same machine.
  • Custom OAuth clients. If you logged in with ZELE_CLIENT_ID and ZELE_CLIENT_SECRET, set the same variables on the other machine.
  • Revoking access (Google account security page, Microsoft account apps, changing the IMAP password) logs out every copy.

To start clean instead, use the headless login on the other machine.

Commands

Mail

zele mail list --limit 100                        # list up to 100 recent inbox threads
zele mail list --filter "is:unread" --limit 100   # list unread inbox threads
zele mail list --folder sent --limit 100          # list sent mail
zele mail list --filter "is:unread" --limit 100 | yq '.[].id' | xargs zele mail read  # read all unread
zele mail search "from:github" --limit 100        # search with Gmail query syntax
zele mail read <thread-id>                        # read a thread
zele mail read 'https://mail.google.com/mail/u/0/#inbox/FMfcgz…'  # read a thread from a Gmail link
zele mail send                                    # send an email
zele mail send --thread-id <thread-id>            # send into an existing thread
zele mail reply <thread-id>                       # reply to a thread (must mail read first)
zele mail reply <thread-id> --dry-run             # show who the reply would go to
zele mail reply <thread-id> --to [email protected]    # override the inferred recipient
zele mail reply <thread-id> --attach report.xlsx  # reply with an attachment
zele mail reply <thread-id> --force               # reply without a prior mail read
zele mail forward <thread-id>                     # forward a thread
zele mail watch                                   # wait for the next new email
zele mail watch --filter "is:unread from:alice"   # wait for a specific email
zele mail watch --timeout 300                     # wait up to 5 minutes

Every command that takes a thread ID also takes the link from Gmail's address bar, and the draft commands take an open draft's link.

mail list defaults to Inbox. Use --folder sent for mail you sent. is:unread on mail list only matches unread Inbox threads. mail search looks in Inbox and Sent on IMAP, and Gmail all-mail on Google accounts.

Reply safety. mail reply and mail send --thread-id refuse to send unless mail read already showed the live last message in that thread. This stops agents from answering a stale view after a new reply arrives. --dry-run does not send, so it skips the check. --force skips it too.

Reply recipients are inferred from the thread, not from the sender of the last message. If the last message is one you sent, the reply still goes to the person you sent it to, and if a thread would only reply back to your own address zele refuses to send instead of quietly mailing you. Check first with --dry-run, override with --to, or opt in with --allow-self.

zele mail reply <thread-id> --dry-run                      # to / cc / subject / In-Reply-To, sends nothing
zele mail reply <thread-id> --to [email protected] --body "…"  # explicit recipient wins
zele mail reply <thread-id> --allow-self --body "…"        # deliberate note to self

Use mail send --thread-id when you want full control over recipients and subject while keeping correct threading (In-Reply-To, References, and Gmail's threadId):

zele mail send --thread-id <thread-id> --to [email protected] --cc [email protected] --body "…"

mail watch blocks until the first new email matching the filter arrives, prints it with the elapsed wait time, and exits 0. Exit 1 means timeout, auth error or another failure; stderr says which. Poll errors are retried and a heartbeat prints every minute, so waiting days (--timeout 259200) is fine.

Check existing replies first. Watch only sees mail that arrives after it starts. mail send and mail reply print the watch command to run next:

zele mail search 'from:[email protected] subject:Question' --account [email protected] --limit 100
zele mail watch --account [email protected] --filter 'from:[email protected] subject:"Question"' --timeout 259200
zele mail read <thread_id> --account [email protected]

Agents should run watch with their shell tool's background mode, so the same agent is notified when it exits. Use completion notifications, not a separate agent or detached & / nohup process. A match is only a candidate: mail read its thread and check that message_id is a new Message ID from the expected sender that replies to the tracked email before telling the user. mail read --verify also shows Message-ID, In-Reply-To and References. If watch returns the same old message again, stop it and report that monitoring is broken. Monitoring never gives permission to send a follow-up.

Body formatting. Write each paragraph as one line. Separate paragraphs with one blank line. Never hard-wrap lines at 72-80 columns: mail clients reflow text themselves, and hard breaks show up as broken mid-sentence lines. Capitalize the first word of every paragraph, also after a greeting that ends with a comma. These rules also apply to drafts you show the user before sending.

zele mail send --to [email protected] --subject "Meeting" --body "Hi Bob,

Can we move tomorrow's meeting to 3pm? I have a conflict in the morning and want to keep the full hour.

Thanks,
Alice"

Mail actions

zele mail star <thread-id>
zele mail unstar <thread-id>
zele mail archive <thread-id>
zele mail trash <thread-id>
zele mail untrash <thread-id>
zele mail read-mark <thread-id>
zele mail unread-mark <thread-id>
zele mail spam <thread-id>
zele mail unspam <thread-id>
zele mail label <thread-id>
zele mail trash-spam

All action commands accept one or more thread IDs and an optional --account flag. On Google accounts, archiving removes the INBOX label. On IMAP accounts, it moves the message to the server's Archive folder (Archive, Archives, All Mail, [Gmail]/All Mail, or INBOX.Archive).

# archive a single thread
zele mail archive 18f3b7c9d2a1e4f0

# archive multiple threads at once
zele mail archive 18f3b7c9d2a1e4f0 18f3b7c9d2a1e4f1 18f3b7c9d2a1e4f2

# archive from a specific account when you have multiple
zele mail archive 18f3b7c9d2a1e4f0 --account [email protected]

# bulk archive: pipe thread IDs from a search
zele mail search "from:[email protected] older_than:7d" --limit 100 \
  | yq '.[].id' \
  | xargs zele mail archive

# list archived threads later
zele mail list --folder archive --limit 100

Search query syntax

For Google accounts, mail search and mail list --filter use Gmail search operators server-side. For IMAP accounts, queries are translated to IMAP SEARCH criteria (a subset is supported). IMAP mail search looks in Inbox and Sent. Use in:sent or in:inbox on mail search to search one mailbox. mail list --folder stays on that mailbox even if the filter has in:.

Operator Example Google IMAP
from: from:github yes yes
to: to:[email protected] yes yes
subject: subject:invoice yes yes
is:unread is:unread yes yes
is:starred is:starred yes yes
has:attachment has:attachment yes yes
newer_than: newer_than:7d yes yes
older_than: older_than:1m yes yes
after: after:2024/01/01 yes yes
before: before:2024/12/31 yes yes
cc: cc:[email protected] yes no
- (negate) -from:noreply yes no
" " (quotes) "exact phrase" yes no
label: label:work yes no
in: in:sent yes yes
filename: filename:pdf yes no
size: / larger: / smaller: larger:5M yes no
OR / { } from:a OR from:b yes no
zele mail list --filter "is:unread" --limit 100
zele mail list --folder sent --limit 100
zele mail list --filter "from:github newer_than:7d" --folder sent --limit 100
zele mail search "from:github is:unread newer_than:7d" --limit 100
zele mail search "in:sent to:[email protected]" --limit 20
zele mail watch --filter "from:github has:attachment" --timeout 300

Drafts

zele draft list
zele draft create
zele draft create --attach report.pdf --attach logo.png  # draft with attachments
zele draft update <draft-id> --attach extra.pdf          # add a file, keep existing ones
zele draft send <draft-id>
zele draft delete <draft-id>

On Google accounts, mail read and the draft commands print a link that opens the thread or draft in Gmail.

Labels (Google only)

zele label list
zele label counts
zele label create <name>
zele label rename <label-id> <name>
zele label delete <label-id>

Filters (Google only)

zele mail filter list
zele mail filter create --from [email protected] --add-label Newsletters --archive
zele mail filter create --subject "invoice" --star --mark-read
zele mail filter delete <filter-id>

Creating and deleting filters needs the gmail.settings.basic Gmail scope. The default Google login cannot grant it yet, so create and delete fail with a message that links to the Gmail filter settings. Listing filters works with every login.

Calendar (Google and iCloud)

zele cal list                     # list calendars
zele cal events                   # upcoming events
zele cal get <event-id>           # event details
zele cal create                   # create an event
zele cal update <event-id>        # update an event
zele cal delete <event-id>        # delete an event
zele cal respond <event-id>       # accept/decline
zele cal freebusy                 # check availability

For iCloud, use calendar IDs from zele cal list with --calendar. These IDs are CalDAV URLs, not email addresses. With one calendar, Zele uses it by default. With several calendars, select one explicitly, or use cal events --all to read them all.

CalDAV updates preserve the original recurrence rules, alarms, exceptions, and provider-specific fields. Date-range queries request expanded occurrences with distinct event IDs. Each occurrence also shows series_id.

Individual CalDAV occurrence changes and whole-series time changes are not supported. Use your calendar app for those operations. A series ID explicitly selects the whole series for other updates or deletion.

Google Meet links, event colors, and creation with --recurrence or --reminder require a Google Calendar API account. CalDAV rejects these options instead of silently ignoring them.

Google shared / subscribed calendars

Zele uses Google CalDAV for calendar access. By default, Google only syncs calendars you own over CalDAV — shared or subscribed calendars (e.g. a partner's calendar) won't appear in zele cal list even after accepting the share invitation.

To fix this, visit Google's CalDAV sync settings and enable the shared calendar:

  1. Open https://www.google.com/calendar/syncselect (logged in as the account you use with zele)
  2. Check the box next to any shared calendar you want to access
  3. Click Save

After that, zele cal list will show the shared calendar and you can query it:

zele cal events --calendar "[email protected]" --week

Why is this needed? Google's CalDAV endpoint only exposes calendars marked for sync (originally designed for mobile device sync). The Google Calendar web UI uses a different internal API, so calendars visible there may not appear via CalDAV until explicitly enabled at the sync settings page.

Attachments

zele attachment list <thread-id>
zele attachment get <message-id> <attachment-id>

Profile

zele profile                      # show account info

Multi-account

All commands support --account <email> to filter by account. Without it, commands fetch from all accounts and merge results.

If providers share the same email, copy the account ID from zele whoami and pass it to --account:

zele cal list --account '[email protected]#imap_smtp'

Commands that take a Gmail thread ID find the account that has the thread, so they work without --account. IMAP IDs repeat between mailboxes and still need it.

Google and IMAP/SMTP accounts work side by side. mail list merges results from both. Google-only labels and filters show an error on IMAP accounts. Calendar commands use Google accounts and iCloud accounts connected with login icloud.

Feature compatibility

Feature Google IMAP/SMTP zele.sh Own domain (Cloudflare)
List, read, search emails yes yes yes yes (search matches text in from, to, subject)
Send, reply, forward yes yes (requires SMTP) no (receive only) yes
Star, archive, trash, mark read yes yes yes archive and trash only
Drafts yes yes no no
Attachments yes yes yes yes
Watch for new emails yes yes yes yes
Date/sender/subject filters yes yes from/to/subject only no
Labels yes no (IMAP uses folders) no no
Filters yes no no no
Calendar yes iCloud via login icloud no no
Gmail search operators full subset (see table above) from:, to:, subject:, is:unread plain text only

Output

All structured data is output as YAML. In TTY mode, keys are colored for readability. Pipe output to other tools for scripting.

For AI agents

Always run zele --help first. The top-level help already contains every subcommand, option, and flag — there is no need to run zele <command> --help separately. The help output is the source of truth. Read it in full — never pipe through head, tail, or sed to truncate.

Never use the TUI. Running zele with no subcommand launches a human-facing terminal UI for browsing email. Agents must use the CLI subcommands (zele mail list, zele cal events, etc.) which output structured YAML that can be parsed and piped.

Always run zele whoami before account-scoped commands. When the user asks to check email "for a specific account" (e.g. "my work email", "my personal Gmail"), run zele whoami first to list connected accounts and find the exact address to pass to --account. Never guess the email — pick it from the whoami output. The output also shows account type (google or imap_smtp) and capabilities so you know which features are available. Outlook accounts show as imap_smtp after zele login microsoft.

# list connected accounts first
zele whoami

# then scope commands to the right account
zele mail list --account [email protected]

Prefer YAML parsing over regex. Pipe command output through yq to extract IDs and fields reliably:

# read all unread emails
zele mail list --filter "is:unread" --limit 100 | yq '.[].id' | xargs zele mail read

# bulk archive unread
zele mail list --filter "is:unread" --limit 100 | yq '.[].id' | xargs zele mail archive

MCP server

zele mcp starts an MCP server over stdio. Every command becomes a tool with the same options: mail list becomes mail_list, cal events becomes cal_events. The tool result is the text the CLI prints: YAML for structured output, readable text for mail read and draft get, and hints or errors in a separate text block.

# Claude Code
claude mcp add zele -- npx -y zele mcp

# Cursor; replace cursor with vscode, windsurf, opencode, claude-desktop, ...
npx -y @playwriter/install-mcp 'npx -y zele mcp' --name zele --client cursor

Log in with the CLI first (zele login). These commands are not tools: login, logout, completions and mail watch.

Every tool takes an account argument (a list of emails), like --account. Pass the email text with body: bodyFile: "-" is refused because stdin is the MCP channel.

Shell Completions

Enable Tab completion for your shell:

zele completions install

Restart your shell (or run autoload -Uz compinit && compinit for zsh). Then Tab works:

zele <TAB>          # shows all commands
zele mail <TAB>     # completes mail subcommands
zele login --<TAB>  # shows available options

Completions stay up-to-date automatically. To remove:

zele completions uninstall

License

ISC

Explore projetos relacionados

Carregando…