UNIX System Administration Handbook - Evi Nemeth [366]
Several command-line utilities allow users to interact with the mail system:
• postfix – starts and stops the mail system (must be run as root)
• postalias – makes the newaliases command work
• postcat – prints the contents of queue files
• postconf – displays and edits the mail configuration file, main.cf
• postdrop – adds messages to the maildrop queue
• postkick, postlock, postlog – provide locking and logging for shell scripts
• postmap – builds database tables, like the UNIX makemap command
• postsuper – manages the queues (run at startup)
Configuring Postfix
About 100 parameters can be specified in the mail.cf file. Most have sensible defaults. The language looks a bit like a series of Bourne shell assignment statements. In the examples below, we have sometimes annotated the configuration statements with a comment that identifies the sendmail equivalent. These comments at the end of configuration lines are not part of the configuration statements; remove the comments if you want to use the statements in your own configuration.
First, let’s define a few variables that will be used later. The myhostname variable defaults to the machine’s hostname. If it’s not fully qualified, set it manually before using it:
myhostname = host.xxx.yyy
The mydomain variable defaults to the parent domain of $myhostname, which Postfix calculates by stripping off the host portion. If this algorithm won’t give the right result, define the domain yourself:
mydomain = local.domain
Both myhostname and mydomain can specify virtual identities.
The mynetworks variable specifies all the networks to which the machine is connected, including the loopback network. For example:
mynetworks = 128.138.243.64/26, 127.0.0.0/8
Postfix understands CIDR notation for the netmask length. The inet_interfaces variable specifies the interfaces that Postfix should listen on (by default, all active interfaces). You need to specify a value for this variable if you use virtual domains.
For the simplest configuration case, you need configure only three variables:
• myorigin – what domain to use in outgoing mail
• mydestination – what domains to receive mail for
• notify_classes – what types of trouble to report to the postmaster
The variable myorigin determines what domain to use for outgoing mail. Use one of the following:
myorigin = $myhostname
myorigin = $mydomain # like sendmail masquerading
The variable mydestination determines the domains for which we will accept incoming mail; it plays the role of sendmail’s use_cw_file feature. The value assigned to mydestination can be a list of hostnames, a domain, a filename, or a lookup table specification. Here are some examples:
mydestination = $myhostname localhost.$mydomain
mydestination = $myhostname localhost.$mydomain $mydomain
mydestination = /etc/mail/local-host-names
The notify_classes clause determines which problems are brought to the attention of the postmaster. Several classes can result in so much mail that it doesn’t get read. The default is
notify_classes = resource, software
which limits the errors to host machine problems and Postfix software problems. Table 19.21 shows the possible classes.
Table 19.21 Values that can be included in notify_classes
Postfix has options for controlling the resources used by the mail system, both rate controls and resource controls.
Postfix can also do limited address rewriting; for example, it can
• Map login names to first.last style addresses
• Trim source route addresses
• Convert UUCP addresses to domain style
• Undo the %-hack
• Add a