Postfix is a Mail Transfer Agent (MTA) designed to be a replacement for sendmail as well as being fast, secure, and easy to configure.
Postfix is designed to replace sendmail, which is the default Mail MTA under FreeBSD.
There are a few ways to install Postfix. The following method will use the (easier) Ports Method, so make sure the Ports Collection is already installed.
Additionally the server will require internet access in order to download updates from the web, so make sure it is able to 'see' the 'net.
I strongly recommend that the following install is performed via SSH using a client such as Putty, rather than directly at the console, as some important information shoots past on-screen during install which can be tricky to read without the ability to 'scroll back up'.
Run the following commands..
Select any extra required options. I selected none..
Ports will download anything extra that is required for the installation, from the internet. You've just gotta love ports.
The installation consists of only two questions..
You need user "postfix" added to group "mail".
Would you like me to add it [y]? y
Would you like to activate Postfix in /etc/mail/mailer.conf [n]? y
And for FreeBSD 5.4 that's about it! However, scroll up and note the following warnings, which shot past at lightning speed..
Message - Editing rc.conf..
If you have postfix configured in your /etc/mail/mailer.conf
(answered yes to the previous question) and would like to enable postfix to start at boot time, then set these variables in your /etc/rc.conf
Save and exit rc.conf
. Although it may not seem like it, the above lines will actually disable Sendmail completely. Which is what you want.
Diverting root's Mail..
It is recommended you divert all emails destined for root
to another user
Prevent unnecessary maintenance..
Disable the following Sendmail-specific daily maintenance routines in /etc/periodic.conf
file (this file may not yet exist and but will be created after saving the following entries.:
Clearing Unwanted Aliases
Finally, run the command..
This will clear any previous aliases from the /etc/aliases.db
file and recreate the aliases database.
Relaying to other Mail Servers
By default the system will not relay to other mail servers, due to spam risks. To fix this edit the config file main.cf
(after backing up the original first)..
cp main.cf main.cf.bak
Scroll down to the # TRUST AND RELAY CONTROL
entries and read the options in the help text found there.
Note that having the default mynetworks_style = host
unhashed is preventing relaying to other mail servers.
For instance, to relay to other servers on the same network, add a hash to the #mynetworks_style = host
line and unhash the mynetworks_style = class
Obviously this whole issue of who the mail server should be able to relay to is a huge one, due to the risk of the thing becoming abused as a spam relayer for some unscrupulous user who finds it and uses it for spamming his or her own crap all over the place.
Hence the main.cf
file does a big number on the various relaying options. Again, read this section and change the settings to yuor own requirements. But be careful you don't allow your Postfix server to relay any more than it has to..
Some Config Notes..
To check your version of postfix, type..
To check your postfix settings, type..
The main config file for postfix is /usr/local/etc/postfix/main.cf
. Make a backup of this file before editing it.
To restart postfix after changing the configuration settings, type
Check for possible errors with..
If your mail server is unable to ping the hostname of the recipient's mail server, then add the name and IP of the recipient's mail server to your server's /etc/hosts
To avoid loopback errors, make sure your hostname entry in /etc/rc.conf
is notated as a fully qualified domain name, i.e. benbox.it.net
Links and References
How Postfix Works
FAQ at Postfix.org
Mailer.conf information at FreeBSD.org
Postfix Basics at Postfix.org