9fans archive / 2000 / 07 / 68 /    prev next

From: bobf@pla...
Subject: 
Date: Tue, 4 Jul 2000 11:44:17 -0400

Re: [9fans] /mail/lib/rewrite

> In /mail/lib/rewrite we will find the line:
> ([^!]*)!(.*) 		| 		"/mail/lib/qmail '\s' 'net!$smtp'" "'\2@\1'"
>
> The corresponding line of second edition was:
> ([^!]*)!(.*) 		| 		"/mail/lib/qmail '\s' 'net!\1'" "'\2'"
>
> In man page, we will find examples of usage of /mail/lib/qmail:
>          ([^!]*.bell-labs.com)!(.*)  |  "/mail/lib/qmail '\s' 'net!\1'" "'\2'"
> and
>          /mail/lib/qmail presotto net!plan9.bell-labs.com ken rob
>
> Where and how can we define $smtp ?

$smtp is defined in the ndb network database; see ndb(6).

$smtp need only be set if your plan 9 system passes all outgoing mail
to another gateway system for delivery.  both prototype rewrite files in
/mail/lib contain a rewrite rule to do this.  however, if you wish
for your system to deliver all mail directly, then replace the rule:

([^!]*)!(.*) 		| 		"/mail/lib/qmail '\s' 'net!$smtp'" "'\2@\1'"

with

([^!]*)!(.*) 		| 		"/mail/lib/qmail '\s' 'net!\1'" "'\2'"

in the rewrite file.

further, if you wish for your plan 9 server to receive messages from other
systems, you will need to use /mail/lib/rewrite.gateway as your prototype
file and add the following rules behind the rule that does local delivery:

# our names
\l!(.*)					alias		\1
(\l\.)?YOURDOMAIN\.DOM!(.*)		alias		\2

these rules strip your system/domain name from the recipient address
to allow the user name to resolve to a mailbox.  replace YOURDOMAIN.DOM
by your domain name and don't forget to escape the '.' characters.

finally, /mail/lib/remotemail is needlessly complex.  i suggest that
you replace

> fd=`{/bin/upas/aliasmail -f $sender}
> switch($fd){
> case *.*
> 	;
> case *
> 	fd=yourdomain.dom
> }


with

fd=YOURDOMAIN.DOM

where YOURDOMAIN.DOM is the domain that you want in the From: line of
outgoing mail.  this should be the same as the YOURDOMAIN.DOM string
in the rewrite rules given above.

i haven't been able to test these changes, so you might have to play
with them a little.

i hope to reorganize the prototype rewrite files and put all of the
changes in the next update to the distribution.