hermes-offline-mail
A Hermes Agent plugin that lets the agent search and
read mail archives on your own machine, without signing in to any mail account and without
internet access. It reads the two formats mail programs keep mail in:
- mbox: one file per folder, each message starting with a
Fromline. Thunderbird keeps every
local and IMAP folder this way (by default), Google Takeout exports Gmail as one.mboxfile, and
mailing-list archives (GNU's, Mailman's) are published as mbox. - Maildir: one file per message in a folder's
cur/andnew/directories. mutt and NeoMutt,
mbsync (isync), OfflineIMAP, getmail and Dovecot use it.
Useful for questions about old mail ("what did the landlord say about the deposit in 2019?"), for a
Gmail export you no longer keep online, or for a mailing-list archive you downloaded, without giving
the agent access to a live mailbox.
The plugin uses Python's standard library only (email, html.parser). It is read-only: it never
sends, moves, deletes or marks mail.
Tools
| Tool | What it does |
|---|---|
mail_folders | Lists the configured folders: id, format (mbox or maildir) and number of messages. |
mail_search | Searches the messages. Every word of query (or "quoted phrase") must appear in the subject, the sender or recipient names and addresses, or the message text; case and accents are ignored (goncalves finds Gonçalves). Filters: folder (a folder or every folder below it), sender, recipient (To or Cc), since and until (YYYY-MM-DD), message_id. Returns the newest matches first, each with folder, id, date, from, to, subject, a snippet around the match, and Gmail labels when the archive has them. |
mail_read | Reads one message: from, to, cc, date, subject, Message-ID, In-Reply-To, Gmail labels or Maildir flags (seen, replied, ...), the text (the plain-text part, or the HTML part as text), and the name, type and size of each attachment. Long messages come back in parts (next_offset). To follow a thread, pass a message's in_reply_to to mail_search as message_id. |
The tools are offered to the model only while at least one path is configured.
Install
hermes plugins install offline-mail --enable
No dependencies.
Configure
plugins:
entries:
offline-mail:
settings:
paths: # mbox files, Maildir folders, or folders holding them
- ~/Library/Thunderbird/Profiles/abcd1234.default-release/Mail
- ~/Library/Thunderbird/Profiles/abcd1234.default-release/ImapMail
- ~/Downloads/Takeout/Mail
- ~/Mail # mbsync / mutt Maildirs
max_chars: 12000 # optional; characters of message text per mail_read call (1000-100000)
A configured mbox file or Maildir is one folder. Any other folder is scanned, up to 8 levels deep and
without following symlinks, for mbox files and Maildirs. Their ids are the configured folder's name
followed by the path inside it, written the way the mail program shows it: Thunderbird's
Local Folders/Inbox.sbd/Lists file is the folder Mail/Local Folders/Inbox/Lists. Thunderbird's
.msf summary files are skipped, and an empty folder (an empty file next to its .msf) is listed with
no messages. Missing paths, and folders with no mail in them, are reported under problems.
Where the files are:
- Thunderbird: the
Mail(local folders) andImapMail(offline copies of IMAP folders)
folders of your profile. Help → Troubleshooting Information → Profile Folder opens it. IMAP
folders are only there if Thunderbird keeps messages for offline use (the default for most
accounts). - Google Takeout: choose Mail at https://takeout.google.com; the download holds
Takeout/Mail/All mail Including Spam and Trash.mbox. - mutt, NeoMutt, mbsync, OfflineIMAP: the Maildir root from your configuration, often
~/Mail
or~/.mail.
What it does on your machine (disclosure)
- Reads only the paths you configure, and only the mail files in them. Your mail is personal
data: what the agent reads goes to the model provider you use, like anything else in a
conversation. Configure only the folders you want the agent to see. - Writes nothing. Files are opened read-only; nothing is renamed, moved or locked. Reading a
message in a Maildir does not mark it as seen (that would rename the file). The tests check that
no file's bytes, size or modification time and no file name changes while all three tools run. - No network, no credentials, no shell commands, no background work. The test suite refuses to
open any socket while all three tools run. Nothing is kept between calls, so another Hermes
profile never sees this profile's folders. - Message text is written by its senders. It is returned as it is (HTML reduced to text, scripts
and styles removed) and may contain instructions aimed at an assistant. The tool description
tells the model to treat it as content, not as requests from you.
Limits
- Each search reads the folders it covers in full; nothing is indexed. On a recent Mac about 2,000
messages a second are searched, so a 50,000-message Takeout export takes about 25 seconds. A
search stops after 60 seconds and says how far it got;folder,since/untilandsender
make searches faster. - Messages over 25 MB (usually large attachments) are matched on their headers only.
- Attachments are listed (name, type, size) but their content is not read.
- An mbox message id is its position in the file. If a mail program rewrites the file (compacting a
folder after deleting mail), an id from an earlier search is refused rather than reading another
message; search again. - Encrypted mail (PGP/MIME, S/MIME) is not decrypted, so only its headers are searchable.
- Not read: Apple Mail's
.emlxfiles, Outlook.pst/.ostfiles and MMDF mailboxes.
Development
python -m pip install pytest
python -m pytest -c tests/pytest.ini tests
OFFLINE_MAIL_REAL=~/Downloads/Takeout/Mail python -m pytest -c tests/pytest.ini tests -k real_world -s
hermes plugins validate .
The tests build archives the way mail programs lay them out: a Thunderbird profile (extensionless
mbox folders, .msf summaries, .sbd subfolders, an empty folder), a Google Takeout mbox with
X-Gmail-Labels, and Maildirs in both the nested (mbsync) and the Maildir++ (Dovecot) layout,
with CRLF line ends and flags in the file names. The messages carry what real mail has:
quoted-printable and base64 bodies, RFC 2047 encoded headers, unlabelled 8-bit UTF-8 headers, an
HTML-only newsletter with a script, attachments, an unknown charset, a message without a date, a
body line starting with "From" that was never quoted and an mboxrd-quoted >From line.
OFFLINE_MAIL_REAL (one or more paths, separated like PATH) adds a test against real archives:
every message of every folder must read, searching for a message's own subject must find it, and no
file may change. It was run against GNU mailing-list archives (bug-bash, bug-coreutils,
help-gnu-emacs; 4,059 messages, 35 MB) and notmuch's test corpora (LKML, attachments, HTML,
broken, encrypted and protected-header messages; 295 messages).
License
MIT
README from the reviewed commit 18ae0b9; it updates when the author re-pins.

nftpoetrist