scramble-mail-repo
This is the scramble.io module for locally storing and indexing email.
It's built on sqlite3 and organizes email by message id, thread id, labels, and full-text search. Boxes--like Inbox, Outbox, and Sent--are handled as a special case of labels. Does not search inside attachments.
Example
Create a new mail repo. Store everything in a given directory:
var ScrambleMailRepo = ; var repo = '/home/bob/my-mail';
Write an email into the repo. Raw RFC2822 format. See test/
for examples.
var sampleMail = "From: <dcposch@scramble.io>\n" + "To: <emma@scramble.io>\n" + "Subject: Yo\n\n"+ "Sup?"; repo;
Search the repo, and print out the results.
// Full text searchrepo;// Full text search includes From and Torepo;// You can also search explicitly. "to:" queries include the CC header.repo;repo;// Search for an exact stringrepo; // Get the inboxrepo;// Get all sent mailrepo; // Fetch a given threadrepo; // Fetch a given messagerepo;
How it works
scramble-mail-repo
stores raw email as flat files in simple directory layout, plus a single sqlite DB to index them.
You specify a directory for everything to go into. Example contents:
index.sqlite
2014/
01/
<scramble mail id 1>.txt
<scramble mail id 2>.txt
02/
...
2015/
...
The sqlite DB uses the fts4 extension for full-text search.
See schema.sql
for the full schema.