154 lines · 3.2 KB · Text
RawDownload
.TH REWRITE 6.SH NAME rewrite \- mail rewrite rules.SH SYNOPSIS.B /mail/lib/rewrite.SH DESCRIPTION.IR Mail (1)uses rewrite rules to convert mail destinations intocommands used to dispose of the mail.Each line of the file .F /mail/lib/rewriteis a rule.Blank lines and lines beginning with.B #are ignored..PPEach rewriting rule consists of (up to) 4 strings:.TF pattern.TP.I patternA regular expression in the style of.IR regexp (6).The.I patternis applied to mail destination addresses.The pattern match is case-insensitiveand must match the entire address..TP.I typeThe type of rule; see below..TP.I arg1An.IR ed (1)style replacement string, with.BI \e nstanding for the text matched by the.IR n thparenthesized subpattern..TP.I arg2Another.IR ed (1)style replacement string..PD.PPIn each of these fields the substring.B \esis replaced by the login id of thesender and the substring.B \elis replaced by the name of the local machine..PPWhen delivering a message,.I mailstarts with the first rule and continues down the list until a patternmatches the destination address.It then performs one of the following actions depending on the.I typeof the rule:.TF alias.TP.B >>Append the mail to the file indicated by expanding.IR arg1 ,provided that file appears to be a valid mailbox..TP.B |Pipe the mail through the command formed from concatenating theexpanded.I arg1and.IR arg2 ..TP.B aliasReplace the address by the address(es) specifiedby expanding.I arg1and recur..TP.B translateReplace the address by the address(es) output by thecommand formed by expanding.I arg1and recur..PD.PP.I Mailexpands the addresses recursively until each address has matched a.B >>or.B |rule or until the recursion depth indicates a rewriting loop(currently 32)..PD.PPIf.IR mail (1)is called with more than one address andseveral addresses match.B |rules and result in the sameexpanded.IR arg1 ,the message is delivered to all those addressesby a single command,composed by concatenating the common expanded.I arg1and each expanded.IR arg2 .This mail bundling is performed to reduce the numberof times the same message is transmitted across anetwork.  For example, with the followingrewrite rule.PP.EX   ([^!]*\.bell-labs\.com)!(.*)  |  "/mail/lib/qmail '\es' 'net!\e1'" "'\e2'".EE.PPif user.B presottoruns the command.PP.EX   % mail plan9.bell-labs.com!ken plan9.bell-labs.com!rob.EE.PPthere will follow only one execution of the command.PP.EX   /mail/lib/qmail presotto net!plan9.bell-labs.com ken rob.EE.PPHere.B /mail/lib/qmailis an.IR rc (1)script used for locally queuing remote mail..PPIn the event of an error, the disposition of the mail depends on the name of thecommand executing the rewrite.  If the command is called.B mailand is run by.BR $user ,the command will print an error and deposit the message in.BR /mail/box/$user/dead.letter .If the command is called.BR rmail ,usually because it was invoked to deliver mail arriving over the network,the message will be returned to the sender.  The returned message willappear to have been sent by user.BR postmaster ..SH "SEE ALSO".IR mail (1)