Now that we've got Postfix installed and running, we'll need to configure it so that it knows about our domain name and how to transfer mail out to other systems.
To configure Postfix
1.
Log in as root, or use su to become root.
2.
cd /etc/postfix
Or, if you're using FreeBSD,
cd /usr/local/etc/postfix
3.
Use your favorite text editor to edit the main.cf file. This is Postfix's main configuration file.
Lines that begin with a # character are comments. Blank lines are ignored.
You can use $variablename to reference another variable configured previously in the file.
The sections mentioned in the steps below are just headings in comments. Postfix's configuration files aren't organized in specific sectionsthe configuration lines can appear anywhere in the file.
4.
Search for the INTERNET HOST AND DOMAIN NAMES section.
5.
Add a myhostname line:
myhostname = full.hostname
Where full.hostname is your fully qualified hostname.
6.
In the SENDING MAIL section, add a myorigin line if you want your email to appear to come from a different domain or host:
myorigin = domain
For example, you might use your ISP's hostname here, or your company's domain name.
7.
In the RECEIVING MAIL section, use the mydestination line to indicate which email needs to be delivered locally. By default, only mail addressed specifically for users on this machine have their mail delivered locally (that is, saved to a mail spool file instead of sent over the network to its destination). For example, to keep mail for the entire domain on this machine:
In the TRUST AND RELAY CONTROL section we need to specify which hosts are allowed to relay mail through this server. The default is to authorize all clients in every subnet the system is attached to. If you're connected to the Internet, this leaves you open to abuse from spammers!
Add a mynetworks line to indicate which IP addresses and networks are allowed to send mail through this system:
mynetworks = 127.0.0.0/8 192.168.0.0/24
This mynetworks line authorizes the local host, plus every host on the 192.168.0.* local network.
9.
To send mail through your ISP's SMTP server, add a relayhost line in the INTERNET OR INTRANET section specifying the ISP's server name:
relayhost = smtp.your.isp.com
10.
Save the file and exit your text editor.
11.
postfix check
Check the Postfix configuration files for errors.
12.
postfix reload
Tell Postfix to reload its configuration data. You don't need to stop/start the server to make configuration changes active.
Tips
Postfix has hundreds of configuration options; look around in the main.cf file and read the many comments to see some of the most useful options. For full documentation, check the Postfix Web site (www.postfix.org).
To add email aliases on a Postfix system, use the information in the "Configuring Sendmail" section earlier in this chapter; Postfix's aliases are compatible with Sendmail's.
You can tell Postfix to immediately reload its email address aliases with the following command, as root:
postfix reload
Webmin has a detailed Postfix configuration section at https://hostname: 10000/postfix/.
To distribute email to client systems that can't (or won't) run a traditional Unix mailer like Sendmail or Postfix, you'll need to install an IMAP or POP3 server. Cyrus IMAP (http://asg.web.cmu.edu/cyrus) and UW IMAP (www.washington.edu/imap) handle these duties.