Applying a template means obtainined select data from an existing mail message (unless --new is specified) and to fill it 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:
These programs follow the usual GNU command line syntax, with long options starting with two dashes (`--'):
I use mailplate as my $editor for mutt, with the following setting in my ~/.mutt/muttrc:
set editor="~/.bin/mail/mailplate --edit --auto --keep-unknown"
mailplate currently has a bit of a limitation, or at least I have not figured out a way how to work around it sensibly yet. If you re-edit a message from mutt's compose menu, it causes mailplate to reprocess the message, which you may not want.
Similarly, if you find yourself editing messages from the index or pager, you probably also don't want mailplate to get in the way. For these cases, I currently use the following two keybindings:
macro compose e ':set my_editor="$editor"<enter>:set editor=sensible-editor<enter><edit-headers>:set editor="$my_editor"<enter>' "invoke normal editor to edit message" macro index,pager e ':set my_editor="$editor"<enter>:set editor=sensible-editor<enter><edit>:set editor="$my_editor"<enter>' "invoke normal editor to edit message"
I am often editing a message with vim and find that I need to use a different identity. For this purpose, I have the following keybindings in my ~/.vim/ftplugin/mail.vim:
nmap <buffer> <F1> :w<CR>:%!mailplate --keep-unknown --auto<CR> nmap <buffer> <C-P><F1> :w<CR>:%!mailplate --keep-unknown private<CR> nmap <buffer> <C-P><F2> :w<CR>:%!mailplate --keep-unknown debian<CR>
Now when I reply to a message, mailplate automatically choses the right template, and if I later change my mind, I can press C-p, to override the choice and select the private template, or just hit to have it re-run the auto-detection.
This manual page was written by martin f. krafft <email@example.com> with help from Carl Fürstenberg.