How to parse email on haraka ?

637 views
Skip to first unread message

Arman Ortega

unread,
Jan 12, 2015, 12:42:38 AM1/12/15
to nod...@googlegroups.com
Hi guys,
Ive been exploring the haraka(node.js smtp server) and Ive successfully install it on my linux machine.
I'm wondering if there is a good tutorial on parsing an email using haraka. Ive check on the manual but I couldn't find it.
Any ideas/suggestions on how to do that would greatly appreciated. Thanks.

Matt

unread,
Jan 12, 2015, 1:13:48 PM1/12/15
to nod...@googlegroups.com
(mostly answered on the Haraka mailing list already, but putting more here so others can benefit)

There's two things in Haraka you have to do to get the email parsed:

1) set `connection.transaction.parse_body = true` in `hook_data` (or one of the earlier hooks, but not before 'MAIL FROM' because that's when the transaction is created).
2) read the stuff you want in `hook_data_post`. You get the body text or html from `transaction.body` and the headers from `transaction.header`,

If you want access to the attachments they are streams, and accessed via events on the transaction.

See the following doc pages:


Note some people don't like the way Haraka parses the email (it does several things to make sure it is efficient, not necessarily easy to use). If you don't like that you can pipe the `transaction.message_stream` into the node "mailparser" module. See https://github.com/andris9/mailparser#pipe-file-to-mailparser

--
Job board: http://jobs.nodejs.org/
New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+un...@googlegroups.com.
To post to this group, send email to nod...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/f3ab0927-636e-46e3-b638-83b3fbdea025%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages