manitou-mdx plugins
The functionalities of manitou-mdx can be extended or customized
by writing Perl modules called plugins, whose structure is described
in the Plugins Reference page.
Some examples of what plugins can do:
- automatically classify a message.
- call external filters such as anti-virus and anti-spam and act upon the result.
- match the sender with another database (customer db, whitelist, blacklist,...)
- route a message, change its priority.
- add additional information in headers or the private note.
- analyze and modify attachments and/or body.
Plugins can be called at different stages of the mail processing,
depending on what kind of functionality they provide:
- incoming_preprocess_plugins are called before
a message is opened and analyzed by manitou-mdx, and have read and write
access to the raw mail file. For example, a sample spamassassin client is
implemented as an incoming_preprocess_plugins, because SA expects
a raw mail file, as does clamav.
- incoming_mimeprocess_plugins are called after the
message has been parsed by manitou-mdx, and before it's put into the
database. These plugins have read/write access to the parsed form of
the message (perl MIME object with decoded parts).
- incoming_postprocess_plugins are called after a
message has been commited into the database and all associated actions
have been carried out.
- outgoing_plugins are called before passing an outgoing
message to the mail system. They can modify the message,
for example by adding a digital signature or additional headers.
- maintenance_plugins can be called periodically by the
mdx to carry out special maintenance tasks such as cleaning up
tables, reclaiming database space, running statistics, issuing
alerts... Maintenance plugins play the kind of role that could
be assigned to crontab scripts, except that:
- they have access to an already opened database connection, and
current configuration options.
- they're not run concurrently with the other mdx functions, such
as importing or sending messages, so that no database access
contention is created.
The distribution archive include those sample plugins, in the scripts/plugins
directory:
- spamc: a pre-process plugin that calls the SpamAssassin client
(spamc) on incoming messages to determine their spam probability and
add a user-defined tag when positive.
- mswordindexer: a mime-process plugin that pass MS-word .doc
attachments on to wvWare,
convert them to Unicode text and add their words to the full-text
index of the body. This allows the user interface's search engine to
retrieve those messages based on the contents of their attachments.
- undouble_newlines: a pre-process plugin that checks and fixes
mailfiles in which all end of lines are doubled, resulting in an incorrect MIME structure.
Apparently, some pop3 servers may deliver mail this way, so activating this plugin
allows to overcome this annoying feature.
- bayes_classify: a mime-process plugin that does automatic mail
classification according to words contained in the message. The so-called
"naive bayesian
algorithm" has recently become popular for its efficiency in spam
filtering, but can
also be used more generally for automated classification:
a Wikipedia entry explains this in detail.
Read
the case study on automatic
language detection for a step by step introduction on how to set up
and use the classifier plugin in Manitou-Mail.
- attach_uploader: an outgoing plugin that replaces large
attachments by a web link to the contents before sending a
message. Such attachments are not welcome in Internet
mail, and sometimes rejected, because they bog down mail
servers, eat people's mailboxes quotas, and may cause trouble
when being fetched.
When this plugin is enabled, large attachments (the inline maximum
size is configurable) are uploaded to an FTP server instead of being
sent along with the mail.
The plugin let Manitou-Mail users just attach files as usual and
let manitou-mdx care whether they should be part of the message or
taken outside.
A plugin is activated by installing the corresponding perl module file
(with a .pm suffix) in the plugins directory, and declaring it in the
configuration file, optionally with arguments, like this:
[common]
plugins_directory = /usr/local/manitou/plugins
# vacuum every 2 hours
maintenance_plugins = 2h vacuum
[mailbox@company.com]
# these plugins will be called only for that mailbox
incoming_preprocess_plugins = spamc("tag for spam")
outgoing_plugins = gpgsign
incoming_postprocess_plugins = guesslang("en","fr") \
anotherplugin(arg1,arg2,...)
See the Plugins Reference page for
detailed technical-oriented information on plugins and how to write
new ones.