Archive

Description

The archive module can be used to archive any passing mail. You can store all mails in a structured directory, based on the recipient or sender domain / address and date. You have to compress the archived mails yourself, but this should be no big problem if you use a time-variable in the archive_dir path.

A possible use case is to run a Decency instance just with this module, implementing an archive. Or you can put it at the very first position to archive really anything .. or the last, and turn of archiving of SPAM mails, to store those mails.

Keep in mind: Decency does not clean up your archive directory. You have to do this yourself, eg via cron-script. An example to clean all archived mails oder then 30 days would be something like this:

# cleanup once per day
0 0 * * *     decency-user  find /var/spool/decency/archive -daystart -mtime +30 -type f -delete

Index database

The Archive module is capable of maintaining an index database which can be used to search / find mails in the archive quickly. Decency itself does not use this database (aside from writing it), its only purpose is for you to implement it (later on, it will be searchable by the planned API).

Configuration

archive_dir

Allowed values: String (path name with variables)
Default: -

The archive modules will store any mail in this directory. The directory might contain variable names and will create non existing directories on the fly.

Variables are:

Examples

Each mail has to be unique, therefore the (unix) timestamp and a random, 6 char length string will be suffixed.

drop

Allowed values: Bool
Default: 0

If this is enabled, any archived mail will be dropped silently (from outside it just accepts the mail) from further process. Useful if you have an archive-only MTA instance.

archive_spam

Allowed values: Bool
Default: 0

Whether to archive mails which are recognized (scored) as SPAM.

use_index_db

Allowed values: Bool
Default: 0

Whether use an index database for the archived mails. The index contains all coordinates (from, to), the subject of the mail (stripped to 255 chars), the full path of the stored mail and an md5 of the mail.

enable_full_text_index

Allowed values: Bool
Default: 0

If the database is enabled, this implies a full text search index is build (a column in which all used, relevant words of the mail are listed). This might slow archiving down and not always required, so it is optional.

Example

---

disable: 0
archive_dir: /var/spool/decency/archive/%ymd%/%recipient_domain%/%recipient_prefix%
drop: 0
archive_spam: 1
use_index_db: 1
enable_full_text_index: 1

SQL

In SQLite, for the search index

-- TABLE: archive_index (SQLITE):
CREATE TABLE ARCHIVE_INDEX ("search" text, "from_domain" varchar(255),
    "subject" varchar(255), "from_prefix" varchar(255), "created" int,
    "to_domain" varchar(255), "to_prefix" varchar(255), "filename" text,
    "md5" varchar(32), id INTEGER PRIMARY KEY);
CREATE INDEX ARCHIVE_INDEX_CREATED ON ARCHIVE_INDEX ("created");
CREATE INDEX ARCHIVE_INDEX_SUBJECT ON ARCHIVE_INDEX ("subject");
CREATE INDEX ARCHIVE_INDEX_FROM_DOMAIN_FROM_PREFIX ON ARCHIVE_INDEX
    ("from_domain", "from_prefix");
CREATE INDEX ARCHIVE_INDEX_TO_DOMAIN_TO_PREFIX ON ARCHIVE_INDEX
    ("to_domain", "to_prefix");

Performance

Fast, cause it just copies the mail. If the index database is enabled, speed goes down according to your database performance.