Email based command interface
Last updated 4 years ago by alinex .
Apache-2.0 · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install alinex-mailman -g
SYNC missed versions from official npm registry.

Package: alinex-mailman

Build Status Coverage Status Dependency Status

Email based interface to control processes. This enables an user to send commands through email. The incoming mails will be scanned automatically, checked and if valid the command will be processed sending back a reply with the command's log.

  • imap mail support
  • filter emails to access
  • authentication possible
  • remote control
  • complete logging

It is one of the modules of the Alinex Universe following the code standards defined in the General Docs.


NPM Downloads

Install the package globally using npm on a central server. From there all your machines may be checked:

sudo npm install -g alinex-mailman --production

After global installation you may directly call mailman from anywhere.

mailman --help

Because this application works agentless, you don't have to do something special on your clients but often some simple changes can make the reports more powerful. If so you will get a hint in the report.

Always have a look at the latest changes.


After the mailman is configured you can start it once using:

> mailman

This will run the manager one time, check the emails run all required commands, send the replies like configured and finish.

The service may run with multiple verbose levels:

  • '-v' - to only show each run and numer of calls per job
  • '-vv' - to display if email is send
  • '-vvv' - to display what is called (with variables)

If the service is running you may also request the online help by sending subject: help me to it's email address.

Run as a service

To run the controller continuously use the daemon option and start it in the background.

> mailman -d -C > /var/log/mailman.log 2>&1 &

This will run the process continuously in daemon mode checking every few minutes for mails to be processed.

For production use you may start it using pm2. pm2 start mailman -- --daemon

Try mode

Mostly for testing you may use the try mode:

> mailman -t

That will run mailman normally but won't change the email so it can be used over and over again. Alternatively you may mark the email as 'unread' to reenable it.


The base configuration for /mailman looks like:

# Configuration for mailman
# =================================================================

# IMAP Server to check for mails
  # Username for login
  # Password for login
  password: mypass
  # Host or IP address to connect to
  # Connection port
  port: 143
  # Secure login, set to true to login through TLS
  tls: false
  # TLS Upgrade decides when to upgrade to a secure session:
  # one of 'always', 'required', 'never'
  autotls: never
  # Connection timeout in milliseconds to wait to establish connection"
  connTimeout: 10s
  # Authentication timeout in milliseconds to wait to authenticate user"
  authTimeout: 5s

# Check interval to recheck for new emails in daemon mode
interval: 5m

And then the commands under /mailman/comand/ will look like:

# Commands
# -------------------------------------------------------------------
  # Object of possible commands to use
    # Title and description used for the mail response
    title: "Get the Date"
    description: "Get the date from the server."
    # Filter rules which define the emails to react on
      # case-insensitive part of the subject
      subject: 'what time is it'
      # address or list of addresses, also as case-insensitive parts
      from: ''
    # Variables to support from body
        type: 'string'
    # Command to execute
      # executional on command line
      cmd: 'date'
      # list of arguments
      args: []
    # response mail settings
      # use the template
      base: default
    # send an email only on error
    emailOnlyOnError: true

Within the args you may use specific parameters given in mail body (but use them all in lowercase). Also the following general variables are present:

  • _mail - the mail object
    • header - some mail header fields like from, cc, bcc, subject, messageId
    • body - text and html body if available
  • _json - complete parameters

So you may use the email address of the sender as _mail.header.from to give it to your command.

The email templates are stored under /email will look like:

# Email Templates
# -------------------------------------------------------------------
  # specify how to connect to the server
  transport: smtp://<<<env://PW_ALEX_COM>>>
  # sender address

  # content
  locale: de
  subject: >
    Re: {{conf.title}}
  body: |+


  Started on {{dateFormat date "LL"}} from {{dateFormat process.start "LTS"}} to {{dateFormat process.end "LTS"}}

  PID {{}}#{{}}

  {{#if result.code}}
  ::: alert
  **{{{result.error}}}** (Code {{result.code}})

  {{#if result.stdout}}
  Output of command was:

  `` ` text
  `` `

  {{#if result.stderr}}
  Error output from command was:

  `` ` text
  `` `


Copyright 2016 Alexander Schilling

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Current Tags

  • 1.3.3                                ...           latest (4 years ago)

21 Versions

  • 1.3.3                                ...           4 years ago
  • 1.3.2                                ...           4 years ago
  • 1.3.1                                ...           4 years ago
  • 1.3.0                                ...           4 years ago
  • 1.2.0                                ...           4 years ago
  • 1.1.3                                ...           4 years ago
  • 1.1.2                                ...           4 years ago
  • 1.1.1                                ...           4 years ago
  • 1.1.0                                ...           4 years ago
  • 1.0.7                                ...           4 years ago
  • 1.0.6                                ...           4 years ago
  • 1.0.5                                ...           4 years ago
  • 1.0.4                                ...           4 years ago
  • 1.0.3                                ...           4 years ago
  • 1.0.2                                ...           4 years ago
  • 1.0.1                                ...           4 years ago
  • 1.0.0                                ...           4 years ago
  • 0.1.3                                ...           4 years ago
  • 0.1.2                                ...           4 years ago
  • 0.1.1                                ...           4 years ago
  • 0.1.0                                ...           4 years ago
Maintainers (1)
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (16)
Dev Dependencies (1)
Dependents (0)

Copyright 2014 - 2016 © |