Need to create a Haraka Plugin , to consume from rabbitmq

45 views Asked by At

I want to create a custom haraka plugin which will enable the mail server to consume from rabbitmq instead of accepting an smtp request and then processsing it.

I created a plugin that will consume from rabbitmq, but I'm stuck at the point where I need to put this consumed message to rest of the haraka flow.

Is there any way that haraka provides this integration , I know that we need to customize "connection.transaction" object but I need to that how I can do it properly.

1

There are 1 answers

0
Moby Duck On

It's possible to generate outbound email in Haraka itself, so you could potentially add something like this into your rabbitmq consumer plugin:

var outbound = require('./outbound');

var to = '[email protected]';
var from = '[email protected]';

var contents = [
    "From: " + from,
    "To: " + to,
    "MIME-Version: 1.0",
    "Content-type: text/plain; charset=us-ascii",
    "Subject: Some subject here",
    "",
    "Some email body here",
    ""].join("\n");
    
var outnext = function (code, msg) {
    switch (code) {
        case DENY:  plugin.logerror("Sending mail failed: " + msg);
                    break;
        case OK:    plugin.loginfo("mail sent");
                    next();
                    break;
        default:    plugin.logerror("Unrecognized return code from sending email: " + msg);
                    next();
    }
};

outbound.send_email(from, to, contents, outnext);

There's a docs section called Creating a mail internally for outbound delivery with more details