0.1.6 • Published 10 years ago

ezmlm v0.1.6

Weekly downloads
2
License
MIT
Repository
github
Last release
10 years ago

Ezmlm wrapper for Node.js

Build Status Dependency Status NPM version

Install

npm i --save ezmlm

Usage

ezmlm = require("ezmlm");

The API looks as follows:

ezmlm.COMMAND(COMMAND_OPTIONS [, CALLBACk]);

whereas COMMAND can be

  • make
  • list
  • sub
  • unsub

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",   // required
  dir:    "./mylist", // default
};

The CALLBACK function takes two parameters, the error object and the result:

var callback = function(err, result){
  if (err)
    return console.error("uuups...");
  // do s.th. with the result
}

If you omit the CALLBACK, you'll get the coresponding command string:

ezmlm.list({name: "foo", type: "mod"}); // returns 'ezmlm-list ./foo mod'

Examples

var listname = "mylist"
ezmlm.make({
    name:     listname,               // required
    domain:   "example.org",          // required
    dir:      "./"+ listname,         // default
    qmail:    "./.qmail-" + listname, // default
    config:   "/etc/ezmlm/de",        // optional
    owner:    "foo@bar.tld",          // optional
    from:     "baz@bar.tld",          // optional
    switches: "AbDfglMrstu"           // optional
    modify:   false                   // default
  },
  function(err){ /* ... */ }
);

ezmlm.list({
    name: "listname",
    type: "mod"
    // possible values: 'mod', 'allow'
    // if omitted the normal subscribers are read
  },
  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); // array of all new addresses
  console.log(ev.type);      // array name (e.g. subscribers)
});

myList.on("unsub", function(ev){
  console.log(ev.addresses); // array of deleted addresses
  console.log(ev.type);      // array name (e.g. moderators)
});

myList.on("error", function(err){
  console.error(err);
});

myList.on("ready", function(){
  myList.subscribers  // array of addresses
  myList.moderators   // array of addresses
  myList.aliases      // array of addresses
  myList.watch(function(){
    // ready to watch changes
    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.

0.1.6

10 years ago

0.1.5

10 years ago

0.1.4

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago