acharkizakaria / haraka-plugin-accounting-files

Haraka plugin that "Retrieve/Store/Archive" custom information of outbound traffic
MIT License
7 stars 7 forks source link
accounting files haraka-plugin outbound storage

ACCOUNTING FILES

Build Status GitHub license Code Climate Greenkeeper badge

NPM

The ACCOUNTING FILES plugin gives you the ability to extract the useful/custom information from the outbound traffic and manage the 'storage/archiving' of the three main types 'Delivered/Deferred/Bounce'.

INSTALLATION

To enable the plugin you must add the name of the plugin "accounting-files" as a separate line inside the plugins file located inside config directory (config/plugins).

You should also place the config file "accounting_files.ini" inside the config directory (More details about the content of this file in the next section).

CONFIG FILE

The config file "accounting_files.ini" contains several parameters that gives you the possibility to customize your plugin.

1. Parameters of the information Log :

INFO: List of the default fields for every type :

2. Parameters of the Archiving mode :

INITIALIZATION

Once installed, the plugin will wait for the start of HARAKA server to be initialized, by reading the config file and checking if the necessary directories are already exist.

There's two cases, if the plugin was already enabled it will create just the files at the start, if it's enabled for the first time, it will setUp the environment by triggering the generation of the all necessary directories and files.

1. Directories generation:

The first generated directory is the main one that will contain all the plugin content, this directory will be created based on the value of the passed parameter path. Inside the previous generated directory the plugin will create a separated directory for every type of the three tracked types 'Delivered/Deferred/Bounce' (The name of these directories will be retrieved from the config parameter location).

If the Archiving mode is enabled, the plugin will add an extra directory for the archiving purpose inside the directory of every type (The name of the directories will be the value of config parameter archive_to).

2. Files generation:

The plugin will generate three separated main files (one file for every type) where the retrieved custom information from the outbound traffics will be stored, every file of them will be located inside the main directory (created previously) of the related type.

The name of the file start by the type 'd/dl/b' followed by the full datetime in the following format (yyyy-mm-dd-HHMMss) and finally the extension, e.g :

d.2017-06-16-125059.tsv
^ ^^^^^^^^^^^^^^^^^ ^^^
| |                 |__ Extenstion of the file (retrieved from the config file)  
| |____________________ Current datetime in `yyyy-mm-dd-HHMMss` format
|______________________ Type of the file (d:delivered, df:deferred, b:bounce)

Every new file has a header that contain the custom fields passed in the config parameter fields, those fields are separated by the separator indicated in the config file separator.

HOW IT WORKS

After the initialization the plugin hook the three principal hooks who follows the send_email :

When the outbound trigger any hook of the three then the plugin will retrieve the necessary fields based on the received arguments from every hook to construct the entry of the current mail and finally append it to the related file.

Archiving mode :

When this option is enabled in the config file by setting archiving parameter to true, the plugin will move all the accounting files to move_to directory of the three types, using two factors time and size :

NOTES

TODO