Configuring the Hostname

Several Postfix parameters affect the name of the Postfix server computer or the hostname that appears in mail headers. The most common of these options are summarized in Table 25.1. In a simple configuration, you needn't adjust anything; Postfix acquires its hostname automatically and builds everything else from there. You can override the configuration if necessary, though—for example, if your computer has multiple hostnames and you want to use the one that Postfix doesn't auto-detect on the mail server, or if obtaining your domain name requires stripping more than one component from the hostname. The masquerade_domains option requires special explanation: This option strips away hostname components if and only if they'll match the specified reduced name. For instance, consider a case in which you've set masquerade_domains = If the server is told to send mail with an address of [email protected], it will reduce this address to [email protected]. If the system is told to send mail with an address [email protected], it won't change the address.

Table 25.1: Common Postfix Hostname Options


Default Value



Computer's hostname, as returned by the hostname command

Computer's hostname; used as a default in many subsequent options. Must be fully qualified (that is, include both the hostname and the domain name).


$myhostname stripped of its first component

Computer's domain name; used as a default in many subsequent options.



The hostname that's appended to outgoing mail if one is omitted by the mail client.



Domains to which an address should be reduced. Domains are tried from left to right in the list until the first match is found.


envelope_sender, header_sender

Types of addresses that are affected by masquerade_domains. Possibilities are envelope_sender, envelope_recipient, header_sender, and header_recipient. If all four options are used, mailing to individual machines in the specified domains will become impossible.



Usernames that should not be masqueraded. For instance, if you set this value to root, root's mail


Default Value

Meaning headers won't be altered.



Changes sender address using a flexible lookup database.

The ultimate in address remapping is accomplished through the sender_canonical_maps option. Point this option at a file using a line such as the following:

sender_canonical_maps = hash:/etc/postfix/sender_canonical

You can then specify hostnames you want changed in the /etc/postfix/sender_canonical file. For instance, to change localhost and the misspelled to on outgoing addresses, use the following two lines: @localhost

You can also include usernames in order to make changes only for particular users' mail. After creating this file and referencing it in /etc/postfix/, you must convert the file to a binary format. Type postmap sender_canonical from the /etc/postfix directory to do this job. You can then tell Postfix to reload its configuration files by typing postfix reload.

0 0

Post a comment