Ezmlm wrapper for Node.js
Install
npm i --save ezmlm
Usage
ezmlm = require("ezmlm");
The API looks as follows:
ezmlm.COMMAND(COMMAND_OPTIONS [, CALLBACk]);
whereas COMMAND
can be
other ezmlm commands are not implemented yet.
Feel free to fork this repo and hack a new feature!
The COMMAND_OPTIONS
object holds the basic and optional parameters.
The basic parameters for most commands are:
var cfg = {
name: "mylist",
dir: "./mylist",
};
The CALLBACK
function takes two parameters, the error object and the result:
var callback = function(err, result){
if (err)
return console.error("uuups...");
}
If you omit the CALLBACK
, you'll get the coresponding command string:
ezmlm.list({name: "foo", type: "mod"});
Examples
var listname = "mylist"
ezmlm.make({
name: listname,
domain: "example.org",
dir: "./"+ listname,
qmail: "./.qmail-" + listname,
config: "/etc/ezmlm/de",
owner: "foo@bar.tld",
from: "baz@bar.tld",
switches: "AbDfglMrstu"
modify: false
},
function(err){ }
);
ezmlm.list({
name: "listname",
type: "mod"
},
function(err, res){
if (err)
return console.error("could not read subscribers: ", err.message);
for (var i in res){
console.log(res[i] + " is a moderator of the " + cfg.name + " list");
}
}
);
ezmlm.sub({
name: "listname",
type: 'allow',
addresses: ["foo@example.org"]
},
function(err){ }
})
ezmlm.unsub({
name: "listname",
addresses: ["foo@example.org"]
},
function(err){ }
);
List class
var myList = new ezmlm.List("foo");
myList.on("sub", function(ev){
console.log(ev.addresses);
console.log(ev.type);
});
myList.on("unsub", function(ev){
console.log(ev.addresses);
console.log(ev.type);
});
myList.on("error", function(err){
console.error(err);
});
myList.on("ready", function(){
myList.subscribers
myList.moderators
myList.aliases
myList.watch(function(){
myList.sub(["new@address.tld"], function(err){ });
myList.sub(["foo@bar.tld"],'moderators', function(err){ });
myList.unsub(["old@address.tld"]);
});
});
Tests
npm test
License
node-ezmlm is licensed under the MIT license.