Postfix mail transfer agent
Postfix version
Tested with Postfix 1.1.11.
Introduction
Postfix is a
mail transfer agent that has a good reputation for being fast and secure.
Debian installs
Exim by default, but we've switched to Postfix because it works quite well with
Sympa virtual hosts.
Installation
Make sure that
/etc/hosts and
/etc/resolv.conf are set up correctly, as described in
StandardConfigFiles. (If you change these later, you'll need to restart Postfix using
/etc/init.d/postfix restart.)
sudo apt-get install postfix
Then install
/etc/postfix/main.cf, changing
myserver and
myserver.example.org for your server's hostname and domain, and changing
10.0.0.240/29 to your network address. If your server isn't meant to handle mail for the
example.org domain (e.g. to
someone@example.org), remove
$mydomain from the
mydestination line.
Make sure Postfix has an alias database:
sudo newaliases
Tell Postfix to reload its configuration:
sudo postfix reload
Maildir mailboxes
We're going to use maildir format for mailboxes, because it's more reliable than the standard mbox format.
Create a file
/etc/procmailrc containing:
DEFAULT=$HOME/Maildir/
Change
/etc/login.defs so it contains:
QMAIL_DIR Maildir/
#MAIL_DIR /var/mail
MAIL_FILE Maildir/
In
/etc/pam.d/login, change the line about
pam_mail.so so it reads:
session optional pam_mail.so standard dir = ~/Maildir/
Make sure the
MAIL environment variable is set in
/etc/profile as described in
StandardConfigFiles.
Tell Postfix to reload its configuration:
sudo postfix reload
Procmail will create each user's
~/Maildir when delivering the first message.
Next, see
StandardSpamassassin for instructions on installing a spam filter.
Testing
Send an email to your normal user account on your server, and see if it arrives. You can check your mail on the server using
mutt.
Make sure your server isn't an open mail relay; test it using the Network Abuse Clearinghouse's
mail relay testing service.
Virtual hosts
In
/etc/postfix/main.cf, this line tells tells Postfix to read a regular expression table containing aliases for addresses in virtual domains:
virtual_maps = regexp:/etc/postfix/virtual
To add a virtual host, add entries to the file
/etc/postfix/virtual. At minimum, you'll need one line to declare the virtual host, as well as lines for
postmaster,
mailer-daemon and
abuse, like this:
# Virtual alias table for example.info
/^example\.info$/ DOMAIN
/^postmaster@example\.info$/ postmaster
/^mailer-daemon@example\.info$/ mailer-daemon
/^abuse@example\.info$/ abuse
The
DOMAIN value in the right column is a dummy entry, but it must be there. The other values in the right column refer to aliases in
/etc/aliases.
After changing this file, run:
sudo postmap /etc/postfix/virtual
If you change
/etc/aliases, run:
sudo newaliases
If you change
/etc/postfix/main.cf, run:
sudo postfix reload
Upgrading
It appears that the variable
virtual_maps has been renamed
virtual_alias_maps in newer versions of Postfix. Keep this in mind when upgrading.
to top