Canonical mapping in Postfix is used for modifying mail in the incoming queue, and it alters both the message headers and the message envelope information for local or remote mail. This mapping can be useful to replace login names with Firstname.Lastname style addresses, or to clean up odd addresses produced by legacy mail systems.
This option specifies the location of the optional canonical address mapping table file. This mapping is applied to both sender and recipient addresses, in both envelopes and headers. This option configures the canonical_maps directive and is disabled by default. Much like the aliases files discussed in the last section, canonical mapping files are specified by a database type and a filename. The accepted database types depend on your operating system, and installed components. Usually hash and dbm are used as the database type. A common choice for this value, then, might be hash:/etc/postfix/canonical.
This parameter configures address mapping only on recipient addresses, and not sender addresses. Mapping is performed on both envelopes and headers. These lookups are performed before the above configured Address mapping lookup tables. This option correlates to the recipient_canonical_maps directive and is disabled by default.
Similar to the previous option, this configures mapping for sender addresses only, and not recipient addresses. Both envelope and header information is modified. This option correlates to the sender_canonical_maps directive and by default is disabled.
Once a filename is selected for any of the canonical mapping tables, it may be edited by clicking the appropriate Edit... buttons. A new page will open, listing any existing mappings and allowing creation of new mappings. The format of mappings in all files is the same.
Canonical mappings may seem, on the surface, to be similar to aliases or virtual domains. However, they are quite distinct and are useful for other purposes. While aliases merely make a decision about which user will receive an email, and virtual domains only impact the envelope address, the canonical mapping alters both the envelope address and the SMTP header address. This change can be used to make mail appear to come from a different user or domain, or direct mail to a different user or domain by changing the adrress on the message.
For example, if I have a number of local subdomains, but would like all mail to appear to originate from a single domain, it is possible to create a canonical mapping to make the translations. In the Edit a Map page, the Name will be a subdomain that is to be mapped to the domain, such as @lab.swelltech.com. The Mapts to... value will simply be the domain I'd like this subdomain converted to, @swelltech.com. After saving the mapping and applying changes, all outgoing mail from lab.swelltech.com will appear to originate from swelltech.com.