GithubHelp home page GithubHelp logo

donfanning / haraka-plugin-aliases Goto Github PK

View Code? Open in Web Editor NEW

This project forked from haraka/haraka-plugin-aliases

0.0 1.0 0.0 14 KB

Email aliases for Haraka

License: MIT License

JavaScript 100.00%

haraka-plugin-aliases's Introduction

Build Status Code Climate Greenkeeper badge NPM

haraka-plugin-aliases

This plugin allows the configuration of aliases that perform an action or change the RCPT address. Aliases are specified in a JSON formatted config file, and must have an action. Syntax errors found in the JSON config will stop the server.

IMPORTANT: this plugin must appear in config/plugins before other plugins that run on hook_rcpt

WARNING: DO NOT USE THIS PLUGIN WITH queue/smtp_proxy.

Configuration

aliases

JSON formatted config file that contains keys to match against RCPT addresses, and values that are objects with an "action" : "" property. Example:

{ "test1" : { "action" : "drop" } }

In the above example the "test1" alias will drop any message that matches test1, test1-, or test1+ (wildcard '-' or '+', see below). Actions may have 0 or more options listed like so:

{ "test3" : { "action" : "alias", "to" : "test3-works" } }

In the above example the "test3" alias has an action of "alias" and a mandatory "to" field. If "to" were missing the alias would fail and an error would be emitted.

Aliases of 'user', '@host' and 'user@host' possible:

{ "demo" : { "action" : "drop" } }
    or
{ "@example.com" : { "action" : "drop" } }
    or
{ "[email protected]" : { "action" : "drop" } }

Aliases may be expanded to multiple recipients:

{ "[email protected]": { "action": "alias", "to": ["[email protected]", "[email protected]"] } }

wildcard notation

This plugin supports wildcard matching of aliases against the right most string of a RCPT address. The characters '-' and '+' are commonly used for subaddressing and this plugin can alias the "user" part of the address.

If the address were [email protected] (or [email protected]), the below alias would match:

{ "test2" : { "action" : "drop" } }

Larger and more specific aliases match first when using wildcard '-' notation. If the above RCPT was evaluated with this alias config, it would alias:

{
    "test2" : { "action" : "drop" },
    "test2-testing" : { "action" : "alias", "to" : "[email protected]" }
}

chaining and circuits

Alias chaining is not supported. As a side-effect, we enjoy protections against alias circuits.

  • optional one line formatting

Any valid JSON will due. Please consider keeping each alias on its own line so that others that wish to grep the aliases file have an easier time finding the full configuration for an alias.

  • nondeterministic duplicate matches

This plugin was written with speed in mind. That means every lookup hashes into the alias file for its match. While the act of doing so is fast, it does mean that any duplicate alias entries will match nondeterministically. That is, we cannot predict what will happen here:

{
    "coinflip" : { "action" : "alias", "to" : "[email protected]" },
    "coinflip" : { "action" : "alias", "to" : "[email protected]" }
}

Due to node.js implementation, one result will likely always be chosen over the other, so this is not exactly a coinflip. We simply cannot say what the language implementation will do and it could change.

action (required)

The following is a list of supported actions and their options.

  • drop

    Drops a message while pretending everything was okay to the sender. This acts like an alias to /dev/null.

  • alias

    Maps the alias key to the address specified in the "to" option. A note about matching in addition to the note about wildcard '-' above. When we match an alias, we store the hostname of the match for a shortcut substitution syntax later.

    • to (required)

    This option is the full address, or local part at matched hostname that the RCPT address will be re-written to. For an example of an alias to a full address consider the following:

    { "test5" : { "action" : "alias", "to" : "[email protected]" } }

    This maps RCPT matches for "test5" to "[email protected]". This would map "[email protected]" to "[email protected]" every time. Compare this notation with its shortcut counterpart, best used when the "to" address is at the same domain as the match:

    { "test4" : { "action" : "alias", "to" : "test4" } }

    This notation is more compact. Mail to "[email protected]" will map to "[email protected]". This notation enables lots of aliases on a single domain to map to other local parts at the same domain.

Example Configuration

{
    "test1" : { "action" : "drop" },
    "test2" : { "action" : "drop" },
    "test3" : { "action" : "alias", "to" : "test3-works" },
    "test4" : { "action" : "alias", "to" : "test4" },
    "test5" : { "action" : "alias", "to" : "[email protected]" },
    "test6" : { "action" : "alias", "to" : "[email protected]" }
}

haraka-plugin-aliases's People

Contributors

msimerson avatar greenkeeper[bot] avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.