Skip to content

Instantly share code, notes, and snippets.

@mattrobenolt
Created March 28, 2011 18:03
Show Gist options
  • Save mattrobenolt/890938 to your computer and use it in GitHub Desktop.
Save mattrobenolt/890938 to your computer and use it in GitHub Desktop.
var MailParser = require("mailparser").MailParser;
exports.hook_queue = function (callback, connection) {
// Parse the mail first...
var mp = new MailParser({fix_smtp_escapes: 0});
var headers;
var body;
var t = this;
mp.on('header', function (h) {
headers = h;
t.loginfo(headers);
});
mp.on('body', function (b) {
body = b;
t.loginfo(body);
});
mp.on('end', function() { t.loginfo('End!'); });
this.loginfo(connection.transaction.data_lines);
connection.transaction.data_lines.forEach(mp.feed);
mp.end();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment