# node-mbox

> mbox parser for Node

Latest version **2.0.0** (published 2023-04-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install node-mbox
pnpm add node-mbox
yarn add node-mbox
bun add node-mbox
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2023-04-06 |
| First published | 2013-09-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=14.0.0 |
| Dependencies | 1 |
| Unpacked size | 14.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Pavel Procházka |
| Maintainers | mafiosso |
| Keywords | e-mail, mbox |

## Links

- npm: https://www.npmjs.com/package/node-mbox
- Repository: https://github.com/SpongeData-cz/node-mbox
- Homepage: https://github.com/SpongeData-cz/node-mbox#readme
- Issues: https://github.com/SpongeData-cz/node-mbox/issues
- npm.io page: https://npm.io/package/node-mbox

## Dependencies (1)

- [line-stream](https://npm.io/package/line-stream.md) ^1.0.0

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 2.0.0 (latest) — 2023-04-06
- 1.0.0 — 2017-11-16
- 0.4.0 — 2017-02-08
- 0.3.0 — 2016-03-30
- 0.2.1 — 2015-09-22
- 0.2.0 — 2015-06-16
- 0.1.1 — 2015-03-22
- 0.1.0 — 2014-09-28
- 0.0.2 — 2013-09-02
- 0.0.1 — 2013-09-02

## README

# node-mbox

mbox file parser for Node.js.

##### Backward incompatibility warning

From version `1.0.0` onwards, message data is passed around as `Buffer` instead of `String`.

You can call `msg.toString([encoding])` to convert to a string, or explicitly set the `encoding` option (see below).

### Install

From the NPM repository:
```
$ npm install node-mbox
```

From the Github repository:
```
$ git clone https://github.com/robertklep/node-mbox.git
$ cd node-mbox
$ npm install [-g]
```

### Description

This module parses mbox files, as described [here](http://qmail.org./man/man5/mbox.html) but not 100% conform to [https://tools.ietf.org/rfc/rfc4155.txt] still. Starting with version 0.1.0, it's pretty speedy, processing a 1.5GB mbox file in about 20 seconds.

Note that this module doesn't parse the mail messages themselves, for which other solutions exist (for example the quite able [mailparser](https://github.com/andris9/mailparser) module from Andris Reinman).

### Example

See the included `example.js`:
```
$ npm install mailparser
$ node example < test/test-4-message.mbox
```

### Options
*  `includeMboxHeader` : predicate if include Mbox header i.e. `FROM ... ...` lines (false by default).

### Usage

```javascript
const {Mbox, MboxStream} = require('node-mbox');
const split = require('line-stream');

// Ways of use.

// 1. pass it a filename
const mbox    = new Mbox({ /* options */ });

// 2. pass it a stream and use custom line splitter.
const fs      = require('fs');
const mailbox = fs.createReadStream('filename');
const splitter= split('\n');
const mbox    = mailbox.pipe(splitter).pipe(new Mbox({ /* options */ }));

// 3. pass it a stream and use default line splitter
const fs      = require('fs');
const mailbox = fs.createReadStream('filename');
const mbox    = MboxStream(mailbox, { /* options */ }); // It does the same as in 2. case.

// Next, catch events generated:
mbox.on('data', function(msg) {
  // `msg` is a `Buffer` instance
  console.log('got a message', msg.toString());
});

mbox.on('error', function(err) {
  console.log('got an error', err);
});

mbox.on('finish', function() {
  console.log('done reading mbox file');
});
```

### Testing

There is a limited number of tests:
```
$ cd /path/to/node-mbox/
$ npm test
```

## License

[MIT](https://raw.github.com/robertklep/node-mbox/master/LICENSE)

---
_Source: https://npm.io/package/node-mbox · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
