Socket
Book a DemoInstallSign in
Socket

scramble-mail-repo

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

scramble-mail-repo

Scramble.io module to store & index mail

latest
Source
npmnpm
Version
0.0.1
Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

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 = require('scramble-mail-repo');

var repo = new ScrambleMailRepo('/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.save(sampleMail);

Search the repo, and print out the results.

// Full text search
repo.search("fifth of november", printResults);
// Full text search includes From and To
repo.search("root@eruditorum.org", printResults);
// You can also search explicitly. "to:" queries include the CC header.
repo.search("to:root@eruditorom.org", printResults);
repo.search("to:root", printResults);
// Search for an exact string
repo.search("\"remember, remember\"", printResults);

// Get the inbox
repo.search("label:\\scramble\\inbox", printResults);
// Get all sent mail
repo.search("label:\\scramble\\sent", printResults);

// Fetch a given thread
repo.getThread("herp", printResults);

// Fetch a given message
repo.getMessage("herp", printResults);

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.

Keywords

scramble

FAQs

Package last updated on 24 Feb 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts