Ich versuche, ein benutzerdefiniertes Plugin für Haraka ein nodejs powered SMTP-Server zu schreiben. Ich möchte dem Mailbody etwas Text hinzufügen. Hier ist mein Code soweit.Haraka Smtp Server (Editing Outbound E-Mail Körper Inhalt)
var utils = require('./utils');
var util = require('util');
exports.hook_data = function (next, connection)
{
connection.transaction.parse_body = true;
next();
}
exports.hook_data_post = function (next,connection)
{
var plugin = this ;
plugin.loginfo(connection.transaction.body.bodytext);
var pos =connection.transaction.body.bodytext.indexOf('\<\/body\>');
connection.transaction.body.bodytext = connection.transaction.body.bodytext.splice(pos-1, 0, '<p>add this paragraph to the existing body.</p> \r \n');
plugin.loginfo(connection.transaction.body.bodytext);
next();
}
String.prototype.splice = function(idx, rem, str)
{
return this.slice(0, idx) + str + this.slice(idx + Math.abs(rem));
};
exports.hook_queue_outbound = function(next,connection)
{
var plugin = this;
plugin.loginfo(connection.transaction.body.bodytext);
next();
}
Wenn das Plugin hier ausgeführt wird, ist das, was es auf dem Protokoll druckt.
Old Körper Loginfo:
[INFO] [-] [add_some_data] <html>
<body>
olddata
<p>add this paragraph to the existing body.</p> \r
</body>
</html>
New Body Log:
[INFO] [-] [add_some_data] <html>
<body>
olddata
<p>add this paragraph to the existing body.</p> \r
</body>
</html>
Was ich möchte wissen, ist, warum es nicht die Daten innerhalb der ausgehenden E enthalten waren.
Wie Sie sehen können, habe ich sogar versucht, den Nachrichtentext innerhalb der "Hook_queue_outbound" einen Haken, der später zu hook_post_data aufgerufen wird, und ich kann das Ergebnis bearbeitet sehen. aber auf der Empfängerseite bekomme ich die alte E-Mail. Ich mache einen dummen Fehler und ich werde sehr schätzen, wenn eine Richtung gegeben wird.
Danke.