Chat with over your 20 years of emails.
- Install Ollama and ensure
ollamadaemon is running. - Python 3.13 with Poetry.
cd mymails
poetry install
# Pull models
ollama pull nomic-embed-text
ollama pull llama3.1OfflineIMAP can be used to sync emails from your email provider to your local machine.
A sample offlineimap configuration syncing emails from iCloud to ~/Mail/iCloud.
file: ~/.offlineimaprc
[general]
accounts = iCloud
ui = ttyui
[Account iCloud]
localrepository = iCloudLocal
remoterepository = iCloudRemote
[Repository iCloudLocal]
type = Maildir
localfolders = ~/Mail/iCloud
[Repository iCloudRemote]
type = IMAP
remotehost = imap.mail.me.com
remoteuser = example@icloud.com
remotepass = some-secret-application-pass
ssl = yes
sslcacertfile = /etc/ssl/cert.pem# run offlineimap
offlineimappoetry run python -m mymails.ingest \
--maildir ~/Mail/iCloud \
--persist ./chroma \
--max-messages 100 \
--resetThe ingestion supports a progress bar, graceful interruption (Ctrl-C), and automatic resume:
- By default, a checkpoint file is written under the persist directory named like
ingest_<collection>.state. Each processed message is recorded by a deterministic base id. - On restart, ingestion skips already-processed messages and continues from where it left off.
- Use
--no-progressto disable the tqdm progress bar. - Use
--no-resumeto force a full reprocess (or--resetto wipe the DB first). - Use
--checkpoint /custom/path.stateto choose a custom checkpoint location. - Use
--batch-size Nto control embedding/upsert batch size (default 64).
poetry run python -m mymails.query \
--persist ./chroma \
--question "What were my travel plans June of 2024?"Optional flags:
--collection emailsto change collection name--model llama3.1to switch the chat model--k 5top-k documents to retrieve--max-messageslimit number of emails ingested for quick tests
On a M3 Macbook Pro, average ingestion time is 2 minutes for 1000 emails.