Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Email processing with NodeJS

I'm writing a Node application which among other things needs to receive email and process it so that it can be rendered in a Web page (as happens in Web mail, list archives, etc.). I've got the receiving part covered with Haraka (https://github.com/baudehlo/Haraka). From there to storing the received emails in Mongo is easy, and so long as they're plain text I can display them.

The part I'm missing is handling the rather involved varieties of ways in which email content can come, including alternatives, HTML, attachments, inlined images, and much more. That's a rather steep amount of functionality to have to put together, and I can't seem to find a JS library that will do it for me. Given the number of libraries out there and the speed at which new ones are added, it might just be that I've missed it — so pointers welcome!

And failing that, if I were to port an existing library for this over from another language, which one(s) would you recommend I look at?

Thanks!

like image 986
Robin Berjon Avatar asked Sep 07 '11 22:09

Robin Berjon


2 Answers

You should check out haraka-couchdb and the other work maxogden is doing.

https://github.com/maxogden/haraka-couchdb

https://github.com/maxogden/couchmail

Haraka-CouchDB deals with storing the attachments. At the very least it should tell you how to do it with Mongo too.

At some point I'm hoping to put a simpler layer over the email parser in Haraka, so that you can just see the email contents easily - but that requires a javascript HTML to Text converter. Or I guess you could do it the other way around and convert the Text to HTML.

like image 182
Matt Sergeant Avatar answered Sep 19 '22 15:09

Matt Sergeant


Im probably a little late responding, But I had a similar requirement for persisting emails in mongo-db. I created this stub of code that gets the body of emails and inserts into mongo, Next iteration is attachments.

The plugin can be found at https://github.com/jamescowie/haraka-mongo

like image 36
James Cowie Avatar answered Sep 19 '22 15:09

James Cowie