Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tootallnate/node-mail-stack
A `StreamStack` subclass that parses raw e-mail messages.
https://github.com/tootallnate/node-mail-stack
Last synced: 5 days ago
JSON representation
A `StreamStack` subclass that parses raw e-mail messages.
- Host: GitHub
- URL: https://github.com/tootallnate/node-mail-stack
- Owner: TooTallNate
- Created: 2011-03-22T20:15:04.000Z (almost 14 years ago)
- Default Branch: master
- Last Pushed: 2011-06-25T16:42:18.000Z (over 13 years ago)
- Last Synced: 2024-12-10T14:04:02.268Z (17 days ago)
- Language: JavaScript
- Homepage:
- Size: 98.6 KB
- Stars: 9
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
node-mail-stack
===============
### A `StreamStack` subclass that parses raw e-mail messages.This module implements [RFC 5322][rfc5322]. Specifically, it parses the
e-mail headers into an Object and fires a "headers" events. Then the
body of the message is emitted as 'data' events, and can be `.pipe()`ed
into other [node][Node] `WritableStream` instances.Usage
-----``` javascript
var smtp = require('smtp')
var mail = require('mail-stack');smtp.createServer(function(conn) {
conn.on('DATA', function(message) {
message.accepted = true;var mailParser = new mail.Parser(message);
mailParser.on('headers', function(headers) {
// 'headers' is an Array, with 'key' and 'value' properties
// for each entry. Duplicate values are handled fine.
// Header names are also attached directly to the 'headers'
// object for programmatic convenience: headers.From -> '[email protected]'
console.log(headers);// Any 'data' events from the parser are part of the message body.
mailParser.pipe(process.stdout, {end:false});
});
});
});
```See the `examples/` directory for some more usage examples.
[Node]: http://nodejs.org
[rfc5322]: http://tools.ietf.org/html/rfc5322