npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ingo2zimbra

v1.0.3

Published

Convert Horde / Ingo filter rules stored using the Horde preferences storage mechanism to a script which can be piped into the Zimbra zmprov command to allow importing of the rules.

Downloads

15

Readme

ingo2zimbra

A node.js command line tool to convert Ingo message filter rules stored using the standard Horde preferences mechanism to Zimbra filter rules.

The script accepts database configuration for the Horde database, and the target mailbox address. As Horde has no concept of separate domains, the domain in the fully qualified address is simply used to create the Zimbra script in the correct format.

The output from the script can be piped to Zimbra's zmprov command line utility to import the converted rules into the target mailbox.

Installation

Yarn is preferred

yarn global add ingo2zimbra

Or use NPM if desired

npm install -g ingo2zimbra

Usage

Basic usage information can be obtained by running:

ingo2zimbra --help
  Usage: ingo2zimbra [options] <mailbox>

  Read Horde / Ingo rules from the preferences database and write a script which can be piped to Zimbra's zmprov command.


  Options:

    -V, --version                       output the version number
    -H, --database-host <host>          Database host (default localhost)
    -P, --database-port <port>          Database port (default 3306)
    -d, --database <database>           Database name (default horde)
    -u, --database-user <user>          Database user name
    -p, --database-password <password>  Database password
    -n, --no-exit                       Suppress writing of exit statements
    -D, --debug                         Write warnings when skipping invalid or unwanted rules
    -h, --help                          output usage information

Options

The database user and database password fields are always required, as is the mailbox.

The no-exit flag will cause the script not to output exit statements after each mailbox, which is useful if it is desired to concatinate the output from multiple calls into a bulk zmprov script, for rule migrations into multiple mailboxes. The script will still output the sm <mailbox> statement before each mailbox.

The debug flag sends debugging output to stderr, see debugging below for more information.

Examples

To generate rules for a single mailbox, the command might be used thus (assuming a local database using the default database name):

ingo2zimbra -u someUser -p SomePassword123$ [email protected] | zmprov
sm [email protected]
afrl "Send mail to my other mailbox" active all address "To" all contains "Some Alias"  redirect "[email protected]" stop
afrl "Mail for another one of my other identities" active all address "To" all contains "Some Other Alias"  redirect "[email protected]" stop
afrl "No big mail please" active all size over "1000K"  discard  stop
exit
exit

To debug the output for a mailbox, to check why some rules might be missing:

ingo2zimbra -D -u someUser -p SomePassword123$ [email protected]
sm [email protected]
# Skipping flag rule "Some Flag Rule" because Zimbra rejects flag rules, even though they are claimed to be valid in the documentation
afrl "No mail from this guy" active any address "From" all contains "Jerk" header "subject"  contains "Something"  discard  stop
exit
exit

To create a bulk migration script, assuming you have a list of mailbox IDs you want to migrate rules for, and the mailboxes are already provisioned and have all folders in place:

for MAILBOX in `cat /tmp/list-of-ids`; do ingo2zimbra -n -u someUser -p SomePassword123$ ${MAILBOX}@target-domain.com >> /tmp/bulk-migration-script; done

# Remember to add two exit statements to the very end, so that zmprov will exit after consuming the script
echo exit >> /tmp/bulk-migration-script
echo exit >> /tmp/bulk-migration-script

zmprov < /tmp/bulk-migration-script
sm [email protected]
afrl "Received faxes" inactive all address "From" all is "[email protected]"  fileinto "INBOX.Faxes" stop
afrl "Some Junk" active all address "From" all contains "Some Spammer <[email protected]"  fileinto "INBOX.trash" stop
sm [email protected]
afrl "Send big stuff to my other ISP" inactive all size over "300000"  redirect "[email protected]" stop
afrl "Unwanted Marketing" active all address "From" all contains "Some Guy"  discard
sm [email protected]
afrl "No Twitter" active all address "From" all contains "twitter"  discard  stop
afrl "No Facebook" active all address "From" all contains "Facebook"  fileinto "Trash" stop
sm [email protected]
afrl "Some Spam" active all header "List-Id"  contains "SPAM.ER" address "From" all contains "[email protected]"  fileinto "INBOX.spam" stop
afrl "Broken spam rule" active all header "List-Id"  contains "[email protected]" address "From" all contains "[email protected]"  fileinto "INBOX.drafts" stop
sm [email protected]
afrl "Send social media stuff to my GMail" active all address "From" all contains "zorpia" address "From" all contains "facebook" address "From" all contains "groupon"  keep redirect "[email protected]" stop
afrl "Throw away some social media stuff locally" active all address "From" all contains "zorp" address "From" all matches "groupon"  discard  stop

Limitations

Some rules are not required or supported by Zimbra, or are not converted because they are not required in a Zimbra environment. Here is a brief list of unsupported or omitted rules:

  • Redirect with reason: This is remapped to a simple discard rule to save on traffic.
  • Whitelist: An internal Ingo rule, this is ignored.
  • Blacklist: An internal Ingo rule, this is ignored.
  • Forwardt: An internal Ingo rule, this is ignored.
  • Vacation: An internal Ingo rule, this is ignored.
  • Rules that check for X-Spam-Flag: This is redundant as Zimbra's default filters will file it correctly into the Junk folder.
  • Rules with the flag action: This is claimed to be supported in Zimbra documentation, but rejected in practice.
  • Rules with invalid condition statements: Ignored
  • Rules with invalid action configurations: Ignored

Debugging

If the output appears to be missing some rules which you expect in the script, you can check if the rules are being intentionally skipped due to the above limitations by requesting debug output using the -D or --debug flags.

This causes the command to write additional output preceded with a #, showing why certain rules are omitted, to the stderr stream.

Development

Pull requests are always welcome and appreciated. We only ask the following as a courtesy to make the PR easier to integrate:

  • All PRs should attempt to roughly follow the existing coding style
  • All changes must be covered by unit tests, included in the PR
  • All unit tests must be passing

Yarn is our preferred package manager for the project. To install all dependencies:

yarn install

To run the tests:

yarn run test

How rules are processed

An in-depth speficication for how rules are processed, generated from the latest output from our Mocha test runner, is available on the Wiki page here:

https://github.com/synaq/ingo2zimbra/wiki/In-depth-description-of-processing