Skip to content

Instantly share code, notes, and snippets.

@baudehlo
Created March 28, 2011 18:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baudehlo/890945 to your computer and use it in GitHub Desktop.
Save baudehlo/890945 to your computer and use it in GitHub Desktop.
var MailParser = require("mailparser").MailParser;
var util = require('util');
exports.hook_queue = function (callback, connection) {
var plugin = this;
// Parse the mail first...
var mp = new MailParser({fix_smtp_escapes: 0});
var headers;
var body;
this.loginfo("parsing mail...");
mp.on('headers', function (h) {
plugin.loginfo(util.inspect(h));
headers = h;
});
mp.on('body', function (b) {
plugin.loginfo(util.inspect(b));
body = b;
});
connection.transaction.data_lines.forEach(function(l) { plugin.logprotocol(l); mp.feed(l); });
mp.end();
callback(CONT);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment