Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
This is a typical XML-RPC server written in JavaScript as of today. There's still more cleanup to do, for example, you shouldn't have to specify flPostEnabled in config, since XML-RPC calls are only made via POST, it can be handled at the lower level.
const xmlrpc = require ("davexmlrpc");
const utils = require ("daveutils");
const davehttp = require ("davehttp");
const mail = require ("davemail");
const fs = require ("fs");
var config = {
port: 1417,
flPostEnabled: true,
flLogToConsole: true,
xmlRpcPath: "/rpc2"
}
xmlrpc.startServerOverHttp (config, function (xmlRpcRequest) {
function mailSend (params, callback) {
var recipient = params [0];
var title = params [1];
var mailtext = params [2];
var sender = params [3];
mail.send (recipient, title, mailtext, sender, function (err, data) {
callback (err, data);
});
}
switch (xmlRpcRequest.verb) {
case "mail.send":
mailSend (xmlRpcRequest.params, xmlRpcRequest.returnVal);
return (true); //we handled it
}
return (false); //we didn't handle it
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.