Postfix Rewriting
Postfix supports rewriting addresses in a few different ways.
Generic
To rewrite addresses as mail is sent, try:
smtp_generic_maps = lmdb:/etc/postfix/generic
A generic(5) file looks like:
root@localdomain [email protected] root [email protected] @localdomain [email protected]
The first part of each line is a pattern. The second part is the address that overwrites a matching address.
Note the second line only rewrites addresses using a domain in $myorigin, $mydestination, $inet_interfaces, or $proxy_interfaces. The matching also happens in that hierarchical order: by full address, then by local part, then by domain part.
Run postmap /etc/postfix/generic and a hashed file will be produced. If your postmap(1) does not use LMDB, replace the lmdb: with whatever algorithm was used.
Canonical
To rewrite addresses as mail is received, try:
canonical_maps = lmdb:/etc/postfix/canonical
A canonical(5) file is structured and hashed in the same way as a generic(5) file.
Recipient Canonical
If only recipient address should be rewritten, but otherwise all of the same behaviors of a canonical(5) file is desired, try:
recipient_canonical_maps = lmdb:/etc/postfix/recipient_canonical