FILTER(1)
NAME
filter, list, deliver, token, vf − filtering mail
SYNOPSIS
upas/filter [ -bh ] rcvr mailbox regexp file [ regexp file ]∗
upas/list add|check patterns addrfile ...
upas/deliver recipient fromfile mbox
upas/token key [ tokenfile ]
upas/vf
DESCRIPTION
A user may filter all incoming mail by creating a world readable/executable file /mail/box/username/pipeto. If the file is a shell script, it can use the commands described here to implement a filter.
Filter provides simple mail filtering. The first two arguments are the recipient’s address and mailbox, that is, the same arguments provided to pipeto. The remaining arguments are all pairs of a regular expression and a file name. With no flags, the sender’s address is matched against each regular expression starting with the first. If the expression matches, then the message is delivered to the file whose name follows the expression. The file must be world writable and should be append only. A message that matches none of the expressions is delivered into the user’s standard mail box. The flags are:
h the regular expression is matched against the message header rather than the address.
b the regular expression is matched against both the header and the body of the message.
For example, to delete any messages of precedence bulk, place in your pipeto file:
/bin/upas/filter -h $1 $2 ’Precedence: bulk’ /dev/null
Three other commands exist which, combined by an rc(1) script, allow you to build your own filter.
List takes two verbs; check and add. Check directs list to check each address contained in the addressfiles against a list of patterns in patternfile. Patterns come in four forms:
~regular-expression
If any address matches the regular expression, list returns successfully.
=string.
If any address exactly matches string, list returns successfully.
!~regular-expression
If any address matches the regular expression and no other address matches a non ‘!’ rule, list returns error status "!match".
!=string
If any address exactly matches string and no other address matches a non ‘!’ rule, list returns error status "!match".
If no addresses match a pattern, list returns "no match".
The pattern file may also contain lines of the form
#include filename
This allows pattern files to include other pattern files. All pattern matches are case insensitive. List searches the pattern file (and its includes) in order. The first matching pattern determines the action.
List add directs list to add a pattern to patternfile for each address in the addrssfile’s that doesh’t already match a pattern.
Token, with only one argument, prints to standard output a unique token created from the current date and key. With two arguments, it checks token against tokens created over the last 10 days with key. If a match is found, it returns successfully.
Deliver delivers into mail box mbox the message read from standard input. It obeys standard mail file locking and logging conventions.
A sample pipeto using the filter kit can be found in /sys/src/cmd/upas/filterkit/pipeto.sample.
A sample pipefrom, /sys/src/cmd/upas/filterkit/pipefrom.sample, is provided which adds all addresses of your outgoing mail to your pattern file. You should copy it into a directory that normally gets bound by your profile onto /bin.
Vf takes a mail message as standard input, searches for executable MIME attachments, wraps them in a warning message, and appends .suspect to any related filenames. /sys/lib/mimetype contains the list of known MIME content types and file extensions. Vf wraps all those for which the fifth field of mimetype is n.
FILES
/mail/box/∗/pipeto mail filter
/sys/lib/mimetype mime content types
SOURCE
/sys/src/cmd/upas/send
/sys/src/cmd/upas/filterkit
/sys/src/cmd/upas/vf
SEE ALSO
aliasmail(8), faces(1), mail(1), marshal(1), mlmgr(1), nedmail(1), qer(8), rewrite(6), send(8), smtp(8), upasfs(4)
Plan 9 — December 28, 2002