home of the madduck/ code/
mailplate: reformat mail drafts according to templates
   mailplate [[--new | -n] | [--editor | -e]] [--keep-unknown | -k]
             [--verbose | -v] [--debug | -d] template-name message-file

   mailplate [--keep-unknown | -k] [--verbose | -v] [--debug | -d]
             template-name < message-data

   mailplate [[--auto | -a] | [--menu | -m]] [[--new | -n] |
             [--editor | -e]] [--keep-unknown | -k] [--verbose | -v]
             [--debug | -d] message-file

   mailplate [[--auto | -a] | [--menu | -m]] [--keep-unknown | -k]
             [--verbose | -v] [--debug | -d] < message data

mailplate is a programme that reformats mail drafts according to a given template. The template may be specified on the command line, but mailplate can also use control information from template files to automatically select an appropriate template (--auto). A selection menu feature is planned (--menu).

Applying a template means obtainined certain data from an existing mail message (unless --new is specified) and to fill them into appropriate slots in the template. Messages are processed in three parts: headers, body, and signature.

When --new is given, an empty instantiation of the template is written to stdout. At the moment, --new cannot be combined with --editor.

The template can define two types of headers: mandatory and preservatory. Mandatory headers take precedence over headers in the existing message and thus overwrite them. Preservatory headers instruct mailplate to port their data from the existing mail message. Headers in the existing message but not defined in the template are dropped, unless --keep-unknown is given.

Body and signature are separated by '-- '. If this sentinel is not found, no signature is extracted. Templates can be interpolated and data filled into slots: helper slots are filled with the output of helper commands (which must be defined in the configuration), environment variable slots are just that, and mail variable slots can be filled with data obtained by running regexps or commands over the message.

This script can be run in multiple ways:

Getting mailplate

mailplate is available in Debian as package mailplate.

The code is available from my Git repository and may be cloned from git://git.madduck.net/madduck/pub/code/mailplate.git.

Todo

In case you want to contribute to mailplate and you don't already have an agenda, have a look at the to-do list.

Legalese

mailplate is © martin f. krafft <madduck@madduck.net> and distributed under the terms of the Artistic Licence 2.0.