xref: /plan9/mail/lib/rewrite.direct (revision e06f534bbaa4097bc6f4764ef1dd2dc3338fbd40)
1#
2#	sample rewrite file for systems that send and receive mail directly.
3#
4#	by default, the return address points to this system; if you have multiple systems
5#	and don't want them all to be mail recipients, set $site to a generic
6#	name (e.g., plan9) or system name in /rc/bin/termrc and /rc/bin/cpurc
7#	and put an MX DNS record in /lib/ndb to point to that system.
8#
9#	replace YOURDOMAIN.DOM in the following rules with your domain name.
10
11# translate local aliases from /mail/lib/namefiles
12\"(.+)\"		translate	"/bin/upas/aliasmail '\1'"
13[^!@.]+			translate	"/bin/upas/aliasmail '&'"
14
15# deliver mail without a domain locally
16local!"(.+)"		>>		/mail/box/\1/mbox
17local!(.*)		>>		/mail/box/\1/mbox
18
19# your local names
20\l!(.*)					alias		\1
21\l\.YOURDOMAIN\.DOM!(.*)		alias		\1
22
23# convert source domain address to a chain a@b@c@d...
24@([^@!,]*):([^!@]*)@([^!]*)		alias	\2@\3@\1
25@([^@!]*),@([^!@,]*):([^!@]*)@([^!]*)	alias	@\1:\3@\4@\2
26
27# convert a chain a@b@c@d... to ...d!c!b!a
28([^@]+)@([^@]+)@(.+)	alias		\2!\1@\3
29([^@]+)@([^@]+)		alias		\2!\1
30
31# queue all mail for delivery
32([^!]*)!(.*) 		| 		"/mail/lib/qmail '\s' 'net!\1'" "'\2'"
33