maddy

Fork https://github.com/foxcpp/maddy

git clone git://git.lin.moe/go/maddy.git

 1# Envelope sender / recipient rewriting
 2
 3`replace_sender` and `replace_rcpt` modules replace SMTP envelope addresses
 4based on the mapping defined by the table module (maddy-tables(5)). It is possible
 5to specify 1:N mappings. This allows, for example, implementing mailing lists.
 6
 7The address is normalized before lookup (Punycode in domain-part is decoded,
 8Unicode is normalized to NFC, the whole string is case-folded).
 9
10First, the whole address is looked up. If there is no replacement, local-part
11of the address is looked up separately and is replaced in the address while
12keeping the domain part intact. Replacements are not applied recursively, that
13is, lookup is not repeated for the replacement.
14
15Recipients are not deduplicated after expansion, so message may be delivered
16multiple times to a single recipient. However, used delivery target can apply
17such deduplication (imapsql storage does it).
18
19Definition:
20
21```
22replace_rcpt <table> [table arguments] {
23	[extended table config]
24}
25replace_sender <table> [table arguments] {
26	[extended table config]
27}
28```
29
30Use examples:
31
32```
33modify {
34	replace_rcpt file /etc/maddy/aliases
35	replace_rcpt static {
36		entry a@example.org b@example.org
37		entry c@example.org c1@example.org c2@example.org
38	}
39	replace_rcpt regexp "(.+)@example.net" "$1@example.org"
40	replace_rcpt regexp "(.+)@example.net" "$1@example.org" "$1@example.com"
41}
42```
43
44Possible contents of /etc/maddy/aliases in the example above:
45
46```
47# Replace 'cat' with any domain to 'dog'.
48# E.g. cat@example.net -> dog@example.net
49cat: dog
50
51# Replace cat@example.org with cat@example.com.
52# Takes priority over the previous line.
53cat@example.org: cat@example.com
54
55# Using aliases in multiple lines
56cat2: dog
57cat2: mouse
58cat2@example.org: cat@example.com
59cat2@example.org: cat@example.net
60# Comma-separated aliases in multiple lines
61cat3: dog , mouse
62cat3@example.org: cat@example.com , cat@example.net
63```