rewrite – mail rewrite rules
uses rewrite rules to convert mail destinations into
commands used to dispose of the mail.
Each line of the file
unhandled troff command .F
is a rule.
Blank lines and lines beginning with
Each rewriting rule consists of (up to) 4 strings:
A regular expression in the style of
is applied to mail destination addresses.
The pattern match is case-insensitive
and must match the entire address.
The type of rule; see below.
style replacement string, with
standing for the text matched by the
style replacement string.
In each of these fields the substring
is replaced by the login id of the
sender and the substring
is replaced by the name of the local machine.
When delivering a message,
starts with the first rule and continues down the list until a pattern
matches the destination address.
It then performs one of the following actions depending on the
of the rule:
Append the mail to the file indicated by expanding
provided that file appears to be a valid mailbox.
Pipe the mail through the command formed from concatenating the
Replace the address by the address(es) specified
Replace the address by the address(es) output by the
command formed by expanding
expands the addresses recursively until each address has matched a
rule or until the recursion depth indicates a rewriting loop
is called with more than one address and
several addresses match
rules and result in the same
the message is delivered to all those addresses
by a single command,
composed by concatenating the common expanded
and each expanded
This mail bundling is performed to reduce the number
of times the same message is transmitted across a
network. For example, with the following
([^!]*\.bell-labs\.com)!(.*) | "/mail/lib/qmail '\s' 'net!\1'" "'\2'"
runs the command
% mail plan9.bell-labs.com!ken plan9.bell-labs.com!rob
there will follow only one execution of the command
/mail/lib/qmail presotto net!plan9.bell-labs.com ken rob
script used for locally queuing remote mail.
In the event of an error, the disposition of the mail depends on the name of the
command executing the rewrite. If the command is called
and is run by
the command will print an error and deposit the message in
If the command is called
usually because it was invoked to deliver mail arriving over the network,
the message will be returned to the sender. The returned message will
appear to have been sent by user