.TH "umpf" 1 .SH NAME umpf \- universal mail processing filter .SH SYNOPSIS .B umpf [-c config_file] [-m default_mailbox] .SH AVAILABILITY Linux only. .SH DESCRIPTION Umpf is a program that reads an e-mail from stdin and according to the config file decides, what to do with it. It is possible to forward the e-mail, filter it through external program and, of course, deliver it to the local mailbox. IMAP support is planned, but not ready yet. .SH OPTIONS .TP .B \-c "\|file\^" Set an alternative location of the config file. .TP .B \-m "\|file\^" Set an alternative location of the default mailbox. .SH CONFIGURATION The program reads a config file (default location is .I ~/.umpf ) and according to the rules provided it decides, what to do with it. If no rule is matched, or some action fails, or the config file cannot be parsed, e-mail is delivered to the default mailbox (default location is .I /var/mail/login , program needs setgid to be able to use it). .SS VARIABLES Variables can be specified in the config file. Their identifiers must start with the letter \fB$\fP, variables have three types that are distinguisghed according to the case of the identifiers. Upper case identifiers are reserved for automatic variables like message size, it is possible to modify them but it is not encouraged. Variables with identifiers starting with an upper-case letter but mixed case otherwise correspond to values of e-mail headers, assigning to them will change the headers. Variables with identifiers starting with a lower case letter are intended for general use. Otherwise, variable identifiers are case-insensitive, ie. $abc refers to the same variable as $aBc, but not the same as $Abc and all of these variables differ from $ABC. .SS AUTOMATIC VARIABLES Config file recognizes these automatic variables: .TP .B $MAIL_LEN refers to the length of the e-mail, including headers .TP .B $LAST_EXIT_CODE refers to the exit code of last external program executed (actions filter or pipe can be used to do it) .TP .B $LAST_OUTPUT refers to the output of last external program executed by action pipe .SS COMMANDS A command is either an action specification or an assignment. All the commands must end with semicolon. Commands can be grouped in blocks bounded by braces. .SS ASSIGNMENTS Assignment is specified in a following way: .P \fILvalue\fB = \fIRvalue\fB ;\fP .P Lvalue is a variable identifier. Rvalue can be variable, a constant (either a string constant that must be given in double quotes or an integer) or an expression consisting of variables, constants and binary operations \fB.\fP, \fB+\fP, \fB\-\fP, \fB*\fP and \fB/\fP, operation \fB.\fP stands for string contatenations, the rest of them are arithmetic operations. Doing arithmetic operations makes sense only on integers. Precedence of the operations can be specified using parentheses, arithmetic operators have a usual priority, string concatenations has the lowest priority. .SS ACTIONS Actions are specified with an arrow operator. .TP .B "-> ;" means "deliver the e-mail to the default mailbox and exit". .TP \fB-> \fIexpression\fB ;\fP means "deliver the e-mail the mailbox specified behind arrow and exit" .TP \fB-> pipe \fIexpression\fB ;\fP means "pipe the e-mail to the external program specified behind pipe keyword". Output of the program is stored in .B $LAST_OUTPUT variable, its exit code is stored in .B $LAST_EXIT_CODE variable. .TP \fB-> filter \fIexpression\fB ;\fP means "pipe the e-mail to the external program and replace it with output of the program". All the header variables, .B $MAIL_LEN and .B $LAST_EXIT_CODE are set accordingly. .TP \fB-> discard ;\fP means just "discard the email and exit". .TP \fB-> mail \fIexpression\fB ;\fP means "forward the e-mail to the address specifed behind the mail keyword and exit" .TP -1 If action fails, the e-mail is delivered to the default mailbox. .P Some of the actions (delivery or forwarding an e-mail) can have keyword copy in front of the arrow, ie. .P \fBcopy -> $mailbox ;\fP .P When copy is specified, the program does not exit after doing an action but continues reading the rules. It also does not deliver to the default mailbox if action fails. .SS CONDITIONS Conditional execution of commands can be specified in a following way: .P \fBif (\fIcondition\fB) { \fI...\fB } .P \fBif (\fIcondition\fB) { \fI...\fB } else { \fI...\fB } .P \fBif (\fIcondition\fB) { \fI...\fB } Ielse if { \fI...\fB } \fI[\fB else { \fI...\fB } \fI]\fP .P where the condition can be a constant, a variable or an expression consisting of following operations: .TP .B "&" is boolean and .TP .B "|" is boolean or .TP .B "^" is boolean xor .TP .B "!" is boolean not .TP -1 A variable or a constant has a boolean value 0, if its value is either "" or "0" and 1 otherwise. .P Expressions can be compared using following binary relations. .P String comparisons: .TP 5 .B ~~ means "matches" (left operand should be string, right one can be a perl compatible regular expression) .TP .B !~ means "does not match" .TP -1 Integer comparisons (does not make sense on strings): .TP 5 .B == means "is equal to" .TP .B != means "is not equal to" .TP .B < means "is less than" .TP .B > means "is greater than" .TP .B <= means "is less or equal than" .TP .B >= means "is greater or equal than" .TP -1 Parentheses can be used to specify a precedence. Boolean operations have greater priority than relation operations. .SS COMMENTS All the text behind a hash character up to the end of the line is ignored. .SH EXIT STATUS .TP .B 0 Success .TP .B 1 Failure .TP .B EX_TEMPFAIL Temporary OS failure .SH BUGS Aer prsenet. .SH TODO IMAP support. .SH AUTHOR Anicka .SH RESOURCES Current version of the program can be downloaded at .B http://www.anicka.net/umpf .SH COPYING The program can be used according to the terms of GPL, version 2.