trewrite - plan9port - [fork] Plan 9 from user space
 (HTM) git clone git://src.adamsgaard.dk/plan9port
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
       trewrite (1060B)
       ---
            1 #
            2 #        sample rewrite file for systems that send mail to a mail server or gateway
            3 #        for delivery.  we assume the mail server handles incoming messages.
            4 #
            5 #        by default the return address points to this system; set $site
            6 #        to the name of the mail server that receives your mail.
            7 #
            8 #        replace YOURDOMAIN.DOM with the name of your domain.
            9 #
           10 #        in the last rule, $smtp is the name of the mail server.  set it
           11 #        in the DNS database in $PLAN9/lib/ndb (see ndb(7)).
           12 
           13 # translate local aliases from /mail/lib/namefiles
           14 [^!@.]+                        translate        "$PLAN9/bin/upas/aliasmail '&'"
           15 
           16 # append the local domain to addresses without a domain
           17 local!(.*)                alias                \1@swtch.com
           18 
           19 # convert source domain address to a chain a@b@c@d...
           20 @([^@!,]*):([^!@]*)@([^!]*)                alias        \2@\3@\1
           21 @([^@!]*),@([^!@,]*):([^!@]*)@([^!]*)        alias        @\1:\3@\4@\2
           22 
           23 # convert a chain a@b@c@d... to ...d!c!b!a
           24 ([^@]+)@([^@]+)@(.+)        alias                \2!\1@\3
           25 ([^@]+)@([^@]+)                alias                \2!\1
           26 
           27 # send all mail to the gateway or mail server, $smtp,  for delivery
           28 ([^!]*)!(.*)                 |                 "$PLAN9/mail/lib/qmail '\s' 'YOUR.MAIL.GATEWAY'" "'\2@\1'"