My name is  
Jurgens du Toit.
Systems Developer.
Problem Solver.

About Me

Technology and Solving Problems are my passion. I'm a South African that loves my wife, life, and coding.

I'm writing a book!

The Logstash Config Guide

Buy it now on Leanpub

07 October 2010

Email Parser for node.js

By Jurgens du Toit

I need to parse Emails in node.js and after looking around on the web, I didn’t find much. Oh, no, I’ll have to write it myself… :)

The source is hosted on GitHub .

Here’s an example:

var   fs        = require('fs')
    , sys       = require('sys')
    , em_parse  = require('./parser_email')

stream = fs.ReadStream(file);
stream.setEncoding('ascii');
stream.on('data', function(data) {
	mail += data;
});
stream.on('close', function () {
	parser = em_parse.parser_email();
	parser.setContent(mail);
	parser.parseMail();
});
blog comments powered by Disqus