slashmail
CLI for searching, managing, and bulk-operating on emails via IMAP. Defaults to localhost:1143 (plain TCP) but works with any IMAP server via --tls.
Install
From crates.io
From GitHub Releases
Download a prebuilt binary from Releases, extract it, and place it on your PATH.
From source
Requires Rust and a C compiler (for OpenSSL bindings).
Platform notes
| OS | Prerequisites |
|---|---|
| macOS | Xcode Command Line Tools (xcode-select --install) |
| Debian/Ubuntu | apt install build-essential pkg-config libssl-dev |
| Fedora/RHEL | dnf install gcc pkg-config openssl-devel |
| Arch | pacman -S base-devel openssl |
| NixOS | nix-shell (uses included shell.nix) |
| Windows | Install Rust via rustup, uses vendored OpenSSL |
Usage
slashmail [OPTIONS] <COMMAND>
Commands:
search Search messages by criteria
delete Search + delete matching messages (move to Trash)
move Search + move matching messages to a folder
export Search + export matching messages as .eml files
mark Search + set/unset flags on matching messages
count Count matching messages (no FETCH)
quota Show mailbox quota usage
status Show per-folder message statistics
Connection options
--host <HOST> IMAP host [default: 127.0.0.1]
--port <PORT> IMAP port [default: 1143 plain, 993 TLS]
--tls Use TLS (required for remote IMAP servers)
-u, --user <USER> IMAP username (or SLASHMAIL_USER env)
Password is read from SLASHMAIL_PASS env var or prompted interactively.
Connection options are global and can appear before or after the subcommand.
Filter options
All commands that operate on messages share the same filter options:
-f, --folder <FOLDER> Folder to search [default: INBOX]
--all-folders Search across all folders (excludes Trash, Spam)
--subject <TEXT> Subject contains
--from <TEXT> From address contains
--since <DATE> Messages since date (YYYY-MM-DD)
--before <DATE> Messages before date (YYYY-MM-DD)
--larger <SIZE> Messages larger than N bytes (supports K/M suffix)
-n, --limit <N> Limit number of results
All filter criteria are AND'd together. Omitting all criteria matches all messages.
Action options
Commands that modify messages (delete, move, mark) support:
--yes Skip confirmation prompt
--dry-run Show what would happen without acting
export supports --yes, --force (overwrite existing files), and -o, --output-dir.
mark takes one or more flags: --read, --unread, --flagged, --unflagged.
Examples
# Search INBOX (all messages, newest first)
# Search with filters
# Show only the 10 most recent matches
# Search across all folders
# Delete with interactive confirmation
# Batch delete (no prompt)
# Preview what would be deleted
# Move messages to a folder
# Export messages as .eml files
# Mark messages as read
# Flag important messages
# Count matching messages (fast, no FETCH)
# Show folder statistics
# Show mailbox quota
# Use with a remote IMAP server (Gmail, Fastmail, etc.)
# Use env vars to avoid typing credentials
Shell completions
# Bash
# Zsh
# Fish
Tested with
- Gmail (via
--tls --host imap.gmail.com) - Fastmail (via
--tls --host imap.fastmail.com) - Dovecot
- Any standard IMAP4rev1 server
How it works
- All filtering runs server-side via IMAP SEARCH
- Uses IMAP SORT extension (RFC 5256) when available; falls back to client-side sort
- With SORT,
--limittruncates results before fetching (fewer bytes over the wire) search,delete,move,mark,countonly fetch headers and size -- never full messagesexportfetches full message bodies viaBODY.PEEK[]- Uses
BODY.PEEKto avoid marking messages as read - UID sets are compressed into ranges and chunked to stay within IMAP command length limits
- Passwords are securely zeroed from memory after login