home of the madduck/ code/ mailplate/

A mailplate template is generally divided into two parts:

When you start up mailplate for the first time, a default template will be generated, along with a default configuration file.

The following is one of my templates, which shows off most of the functionality:

 1: * 10 ^(?:To|Cc|From): .+@(?:.+\.)*debian\.(org|net)
 2: * 8 ^(?:To|Cc): .+@(?:.+\.)*backports\.org
 3: * 8 ^(?:To|Cc): .+@(?:.+\.)*debconf\.org
 4: From: martin f krafft <madduck@deXXXn.org>
 6: Organization: The Debian project
 7: X-OS: Debian GNU/Linux $(get_debian_version) kernel $(get_kernel)
 8: X-Motto: Keep the good times rollin'
12: -- 
13:  .''`.   martin f. krafft <madduck@deXXXn.org>
14: : :'  :  proud Debian developer, author, administrator, and user
15: `. `'`   http://people.debian.org/~madduck - http://debiansystem.info
16:   `-  Debian - when you have better things to do than fixing systems
18: $(get_quote)

Let's see if we can make sense of these 18 lines:

Advanced interpolation

As you can see from the above, mailplate can interpolate parts of the template, and it wouldn't be much use if it could not. But it gets better: mailplate can also interpolate two additional types of data sources. We shall use another, contrived example to show this off:

1: * 1 ^(?:To|Cc): (?P<rname>[^ ]+).+$
4: Hello %(rname)s,
6: my shell of choice is ${SHELL}.
8: --·
9: martin

Running commands during scoring

Instead of regular expressions, you can also run commands during the automatic template selection process. If the command returns with a zero exit code, the score is added. Commands are executed by the shell, and they have to swallow stdin, which is arguably a bit bulky and could be improved, but:

! 99 cat; case "$(date +%a)" in Sat|Sun) exit 0;; esac; exit 1

I don't work on weekends!


A more sensible use-case would be to call egrep in case you hate Python regular expressions (like me).